- Home /
Script doesn't work with framerate drop
Hey everyone! I have this script which adds force to the player when a button is pressed. Works great when the framerate is smooth, but doesn't work at all when the game slows down by any amount.
Any idea what would cause this?
var player: GameObject;
var force : float = 10.0f;
var forceUp : float = 20.0f;
function Update () {
qtePic1.active = true;
qtePic2.active = false;
delayBefore();
//qtePic.active = false;
if(Input.GetKey(KeyCode.Z)){ //getkey
player.GetComponent.<Rigidbody>().AddForce(transform.forward * force);
player.GetComponent.<Rigidbody>().AddForce(transform.up * forceUp);
player.GetComponent.<Rigidbody>().AddForce(transform.forward * force, ForceMode.Impulse);
player.GetComponent.<Rigidbody>().AddForce(transform.up * forceUp, ForceMode.Impulse);
}
Comment
Best Answer
Answer by Vicarian · May 20, 2018 at 01:44 PM
Don't call anything physics related from Update(). Use FixedUpdate() instead. That'll alleviate some of the frame issues.