I can’t figure out what’s causing my cube to fly off to the sky and outside of the frustum view.
var velocity_y = 0f;
if(body.velocity.y < -speed+2f)
{
velocity_y = -speed+2f;
}
else
{
velocity_y = body.velocity.y;
}
if (jump)
{
body.AddForce(0, 300, 0);
jump = false;
}
else
{
body.velocity = (Quaternion.Euler(0, cam.transform.eulerAngles.y, 0) * new Vector3(h, velocity_y, v) * speed);
}
Above code is in FixedUpdate. My jump bool is turned true in the Update when space is pressed with getkeydown.
This is what happens to my cube guy:
63ab0
It flies off to the sky forever! I’ve been trying all kinds of combinations. I tried doing the body.velocity = Vector3.up * speed thing and adding it to the body.velocity, still flies off. What’s causing it to fly off?