Hello everyone, I have a racing game and my camera simply follows the car. But I want my camera to get closer to the car when the car slows down. For example I’m driving with 50 mph , and I stop pressing to the gas key, the car is now free and simply slows down. As it is slowing down, I want my camera to get closer to it slowly. But how can I calculate if it is slowing down ?
If your car is handled by physic, check lastVelocity (you got to create that one) and rigidbody.velocity.sqrMagnitude (you don’t need the length, just if it’s higher or lower, so save yourself a sqrt).
If not, calculate the velocity yourself with transform.position.