From 92da5013a410b3a02f1e976f29358d54124d5e99 Mon Sep 17 00:00:00 2001 From: Jack Rus Date: Fri, 31 Jan 2020 21:09:16 -0500 Subject: [PATCH] bug sprite added --- Assets/BugMovement.cs | 49 ++++ Assets/BugMovement.cs.meta | 11 + Assets/Sprites/Bug - Level 1.png | Bin 0 -> 78 bytes Assets/Sprites/Bug - Level 1.png.meta | 347 ++++++++++++++++++++++++++ 4 files changed, 407 insertions(+) create mode 100644 Assets/BugMovement.cs create mode 100644 Assets/BugMovement.cs.meta create mode 100644 Assets/Sprites/Bug - Level 1.png create mode 100644 Assets/Sprites/Bug - Level 1.png.meta diff --git a/Assets/BugMovement.cs b/Assets/BugMovement.cs new file mode 100644 index 0000000..88b642c --- /dev/null +++ b/Assets/BugMovement.cs @@ -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(); + bugWidth = this.GetComponent().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() + { + + + } +} diff --git a/Assets/BugMovement.cs.meta b/Assets/BugMovement.cs.meta new file mode 100644 index 0000000..3816a84 --- /dev/null +++ b/Assets/BugMovement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e5f777aa09d2ced42baa1cc6bf9dbe54 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Bug - Level 1.png b/Assets/Sprites/Bug - Level 1.png new file mode 100644 index 0000000000000000000000000000000000000000..8eb1b1ecc13b6e1d2375151866134cd7a040340c GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=L_J*`LpWrU|M0W$cr!i aF)*;jval%k