bug sprite added

This commit is contained in:
Jack Rus
2020-01-31 21:09:16 -05:00
parent 137d74733b
commit 92da5013a4
4 changed files with 407 additions and 0 deletions

49
Assets/BugMovement.cs Normal file
View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BugMovement : MonoBehaviour
{
public LayerMask layerMask;
public float speed;
Rigidbody2D bugBody;
Transform bugTrans;
float bugWidth;
// Start is called before the first frame update
void Start()
{
bugTrans = this.transform;
bugBody = this.GetComponent<Rigidbody2D>();
bugWidth = this.GetComponent<SpriteRenderer>().bounds.extents.x;
}
// Update is called once per frame
void Update()
{
// CHECK IF GROUNDED
//Vector2 lineCastPos = bugTrans.position - bugTrans.right * bugWidth;
//bool isGrounded = Physics2D.Linecast(lineCastPos, lineCastPos + Vector2.down, layerMask);
//if (!isGrounded)
//{
// Vector3 currentRotation = bugTrans.eulerAngles;
// currentRotation.y += 180;
// bugTrans.eulerAngles = currentRotation;
//}
// Move Forward
Vector2 bugVelocity = bugBody.velocity;
bugVelocity.x = speed;
bugBody.velocity = bugVelocity;
}
void FixedUpdate()
{
}
}