Non Kinematic Rigidbody: Move At Same Velocity Gotchas

Goal: Create a simple platformer. Simple = direct movement with same velocity always.

Must use Non Kinematic RigidBody. Why ? Kinematic ones aren’t affected by collisions and pass through walls. Dont want to use CharacterController.

Approach 1: The Suggested Unity Way:

_rigidbody.AddForce(direction, ForceMode.VelocityChange);

Problem a: Requires 1-2 seconds to build towards max velocity. My goal is to obtain max velocity in 0 seconds time, and remain unchanged while button is pressed. For a platformer game this means that the player will fail to dodge bullets = gameover. Reversing move direction takes 4 seconds time, this is hopeless…

Problem b: takes 5-6 sec time for player to stop moving (sliding on ice effect). This causes the player to fall of the ledge = gameover.

Approach 2: Set Velocity Directly:

_rigidbody.velocity = direction;

Doesn’t suffer from A or B. This is the perfect controller for my needs. Exactly what i want.

Questions:

  1. is there a hidden gotcha i need to care? According to Unity:

    In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour. Don’t set the velocity of an object every physics step, this will lead to unrealistic physics simulation.

Unity not only treats me as a “noob”, but forbids me to use this approach without specifying what bad is gonna happen. i just did “Bad case” and no nuclear factories exploded, I was going to manually simulate gravity, friction, and external forces applied to player anyway. What should i watch for? Will it be slow?

  1. Does interpolation mode have any effect if i use such “control”. If not i can set it to None to save Cpu.
  1. Unity does indeed tell you what’ll happen if you set velocity directly: “this will lead to unrealistic physics simulation.” Since it doesn’t sound like you care about an accurate physics simulation for your game, you should be fine!

  2. Interpolation can smooth out some physics movement, like if you were to move your camera in normal Update while moving your player in FixedUpdate (as an example), so you may want to enable it if you’re noticing any choppy movement.