I'm trying to create a simple platforming game. I have an animated platform moving in 2 opposite directions. I use this simple code to make the character move along with the platform while he is standing on it:
public class PlatformMoving : MonoBehaviour
{
private void OnTriggerEnter(Collider other) => other.transform.parent = transform;
private void OnTriggerExit(Collider other) => other.transform.parent = null;
}
The character moves with CharacterController.Move()
. When he stands still on the platform and movement vector equals to Vector3.zero
, he moves in the direction opposite to the platform movement direction and can even fall down from the platform. But if I comment charController.Move(movement)
line in a character motion script, everything works properly and the character does not move when he shouldn't do that. How to solve it?
movement vector != Vector3.zero
. Like, try adding checkif (movement != Vector3.zero) { charController.Move(movement); }
\$\endgroup\$