- Home /
3D RPG Character Movement
The problem:
I am working on a 3D RPG and am currently stuck trying to decide how to allow the player to move their character throughout the world. I've spent the last few days reading about CharacterController and the Rigidbody, but I can't seem to make a clear distinction about what I need to do. I don't want to get too far into this project and then realize I've wasted a bunch of time and effort since I used the wrong movement approach so I'm looking for some experienced input.
Goals:
In the game I want the character to be able to move forward, backward, strafe, turn, jump, walk, swim, run, go up and down stairs/slopes, be affected by "gravity", and possibly other things that you do in a 3D RPG. I don't want the character to affect the position/movement of scenery/objects in the game when ran into, I don't want enemies to affect the position/movement of the character when ran into, and I don't want the character to affect the position/movement of the enemies when ran into. I do want to prevent the objects/scenery, enemies, and character from moving through each other. I want to be able to turn gravity on/off or ignore when needed for swimming/spells/other. There would be very few instances that physics simulations would be required - they would be very simple and could be accomplished through scripting without the physics engine if need be (player being thrown back in a simple arc from explosion). Side note - If I extended this to multi-player I wouldn't want players to collide with each other.
My thoughts:
I don't know if a CharacterController would suite my needs since it's limited to the capsule collider. I wonder if later I would want a mesh collider on my character since it will have limbs/joints/etc. Another thing that I don't know is since I don't really need physics (aside from preventing objects from moving through eachother) would I even need a mesh collider, or would I still need it to prevent all parts of the character from going through other objects? The CharacterController does come with a lot of pre-built functionality that I'm looking for, but it seems that the rigidbody would be easier to modify for my purposes. Since the controller is pre-built maybe there are some things that I want to accomplish that wouldn't be possible due to how it's set up?
The rigidbody is the way that I felt I should go. I like being able to switch gravity on/off easily. However I don't know how to set up the player, enemies, and other objects to achieve the functionality that I want. These are some of the things that I did with a cube w/ rigidbody and my character w/ rigidbody. Used freezed rotation so the player doesn't fall over while moving or hitting the wall while the player is non-kinematic.
Kinematic wall and kinematic player - Pass through each other, neither prevents the other from doing so, this is expected.
Kinematic wall and non-kinematic player - Wall isn't moved which is great, player bounces off of wall slightly which would need to be fixed. If using this approach I don't know what I would use for the enemies as far as the rigidbody setup. Since the player is non-kinematic it could be affected by enemies colliding into it which I don't want.
Non-kinematic wall and kinematic player - Player knocks over the wall, freezing the walls rotation makes it just get moved without falling over, freezing position and rotation causes the player to move through the wall as if they were both kinematic.
Non-kinematic wall and non-kinematic player - Player knocks over wall, freezing rotation on wall causes it to just be pushed back, freezing rotation and position on wall causes it to launch the player away, and freezing the position and rotation on both the wall and player cause them to move through each other like two kinematic rigidbodies.
If I set my character to kinematic then I can easily move the character around like I want to except for the gravity (which I'm assuming could somewhat easily be simulated). I was using rigidbody.MovePosition to attempt all of this and I believe that approach is a correct one. I feel like there is a way to do what I want with the rigidbody and I also feel that the rigidbody is the correct way to go. Is one of these set-ups preferred or optimal to go with and modify?
Am I missing something fundamental here or a small key piece of info? I thank any help/responses in advance and am open to all suggestions. Also if anything I said here is inaccurate please let me know, it might help me solve my dilemma.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131206im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Turning a rigidbody controller into a character controller (almost) 1 Answer
Rigidbody Jumping for Character Controller 1 Answer
Character Controller Follow me in the air 1 Answer
Using rigidbody for collisions only, not movements? 1 Answer
How to let a GameObject generate force but not be affected by certain forces? 0 Answers