Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Something wrong with my movement script...

$
0
0
Just a quick point-out: This script SHOULD have bools to move, I did not do it out of lack of programming experience. I did this so I can access the movement from other scripts whilst still having it move... However it seems like it is due to my lack of programming experience, otherwise I wouldn't be here seeking the wisdom of your beautiful gray-matter. Something is wrong, it is not moving. Can someone assist me? Or perhaps suggest a better approach? Thanks in advance :D Here is my script: using UnityEngine; using System.Collections; public class Movement : MonoBehaviour { public static bool IsAlive = true; public static bool isMovingRight = false; public static bool isMovingLeft = false; public float speedVar; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetKey(KeyCode.A)) { isMovingLeft = true; } if(Input.GetKey(KeyCode.D)) { isMovingRight = true; } //SWAGDIVIDERALLHAILLORDSWAGAXXUSPLZNOMALFURIONSPAMMANYLEGENDARYDOGECATELOGE if(isMovingLeft = true) { transform.Translate(Vector3.left * Time.deltaTime * speedVar); } if(isMovingRight = true) { transform.Translate(Vector3.right * Time.deltaTime * speedVar); } if (transform.position.x > 5) { transform.position = new Vector2(5, transform.position.y); // can't go further than 5 } else if (transform.position.x < -5){ transform.position = new Vector2(-5, transform.position.y); // can't go further than -5 } } void OnCollisionEnter(Collision other) { if(other.gameObject.CompareTag("Kill")) { Death(); Destroy(this.gameObject); } } void Death() { IsAlive = false; PlayerPrefs.SetInt ("Score", Score.scoreValue); } } Thanks so much you magnificent community :D

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>