In a 3D game, I have NPC:s controlled by RichAI + RVOController.
Player movement is either manual (via CharacterController) or with RichAI + RVOController (in cutscenes and the like).
Question: What is the right approch for moving the player?
If I move player with CharacterController.Move() player can push NPC:s and vice versa (which is nice).
If I move with RVOController.velocity, NPC can not push player. (In this case I find having a CharacterController is still nice to get collisions with walls etc.). I read that using RVOController.velocity is the best way to go. Why? Any benefits vs CharacterController.Move() in this case?
“Keyboard movement without pathfinding” fits my case best, with some changes:
For my use case, I have a RichAI component on the player which is enabled all the time, to avoid that the player can walk through NPCs, and to able to be pushed by NPC:s. Because of that, I do not update the transform.position, because that would result in a double movement (by RichAI and transform.position …).
When the player moves, I set RVOController.velocity, and when there is no input, I do NOT set velocity, to allow NPC:s to push player when not moving. Likes this:
private void Update() {
float x = Input.GetAxis(HORIZONTAL);
float z = Input.GetAxis(VERTICAL);
Vector3 move = transform.right * x + transform.forward * z;
if (move.sqrMagnitude > float.Epsilon) {
_rvoController.velocity = move * speed;
}
}