Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Why does my object go so high?

$
0
0
In the Update() of my enemy script, I have it so that the object will Translate up based on speed and time however the first object that is spawned goes beyond the limit I've set at 2.5 while the rest that get spawned work fine. Why is this? public class EnemyScript : MonoBehaviour { int scoreValue = 1; public int speed = 1; // Use this for initialization void Start () { } private void OnMouseDown() { Destroy(gameObject); } // Update is called once per frame void Update () { if(this.transform.position.y <= 2.5f) { this.transform.Translate(Vector3.up * speed * Time.deltaTime, Space.World); } } private void OnDestroy() { GameManager.IncrementScore(scoreValue); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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