I am trying to code a movement similar to Flappy bird where when I click the button the player jumps.
However whenever the FPS changes the movement change, I understand this is because I am using update() to move the character.
I was taught that if you multiply a value with Time.deltaTime it wouldn’t change. But alas it seems to persist, and there are times when the time.deltaTime value spikes.
What do I do in this scenario?
The code I am using basically gives the player a constant downward acceleration. This makes the velocity goes to the negative. When I want the player to jump, I give it a positive velocity so it flies upwards. Essentially, Flappybird.
void Update () {
transform.position = new Vector3(
transform.position.x,
transform.position.y + (flightDropVelocity * Time.deltaTime),
transform.position.z);
flightDropVelocity = flightDropVelocity + flightDropAcceleration;
}
public void Flight(){
flightDropVelocity = 250f;
}