This commit is contained in:
Jack Rus
2020-01-31 21:21:14 -05:00
parent c7c8c1f67d
commit a610edc143
2 changed files with 150 additions and 28 deletions

View File

@@ -6,39 +6,15 @@ public class BugMovement : MonoBehaviour
{
public LayerMask layerMask;
public float speed;
private bool movingRight = true;
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;
}
private Transform groundDetection;
// 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;
transform.Translate(Vector2.right * speed * Time.deltaTime);
}
void FixedUpdate()