Quantcast
Channel: Questions in topic: "independent"
Viewing all articles
Browse latest Browse all 102

Why is this small part of code not frame independent ?

$
0
0
I have this code and been messing around with time.deltatime for quite a long time now, not sure why it isnt frame independant, please help. void Update() { Vector3 velocity = bulletSpeed * transform.forward + gravity; //Debug.Log (transform.position); //Debug.Log (velocity); gravity += new Vector3 (0, -9.8f, 0); newPos = velocity * Time.deltaTime + transform.position; direction = newPos - oldPos; float dist = direction.magnitude; if(Physics.Raycast(oldPos,direction,out hit,dist,layersToCheck)) { //Debug.Log("hit Object name: " + hit.collider.gameObject.name); Destroy(gameObject); } else { oldPos = transform.position; transform.position = newPos; }

Viewing all articles
Browse latest Browse all 102

Trending Articles



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