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;
}
↧