- Home /
Moving a 3D player without player controller
Hello,
I've been looking at making a 3D character for a sort of platformer.
The character walks, rotates, jumps...
Obviously, I would like to make use of unitys Physics for everything.
I came to the first step, get the block to move, and land on platforms! There is a PlayerController script, but I would like and try my hand at making my own movement, collision logic, etc...
I tried to update his position, and velocity, directly. The position does not collide correctly The velocity tips the guy over Locking the rotation for X and Z does not let the guy move straight foward, he wiggles.
Basically, I came to the realization that I have no idea of the correct implementation for this. Any suggestions?
Thanks!
Answer by sparkzbarca · Oct 19, 2012 at 03:03 AM
you dont update velocity, you addforce. But for a player IT MAKES VERY little sense to use physics. Because your going to want him to violate it. THats why there is a charactercontroller.
You dont want to limit him to a 10 inch jump and stuff, so you'd just be using physics to give him unrealistic results. But if you want to.
you can locking him to the terrain by ensuring his forward is parallel to the ground. if you take player.transform.right and you crossproduct it with the global up, or if you have hilly terrain with the terrain normal you get from a raycast at the ground, you can get what his forward should be and normalize it and then set his forward to that.
If you dont understand that you can ask for some detail and i'll try to explain it. :)
I get what you mean for checking against the current "Ground" but not about actually moving him.
Don't use the real physics, got it. But I still need to fake some things, like falling, right? I cant update the position, physics won't work. I require a RigidBody, right? The way you are telling me, it sounds like all I need is a box collider. Does unity have all the collision detection and "pushing" out of colliding objects built in for these guys?
Thanks man :)
Your answer
Follow this Question
Related Questions
Make character not move through walls and other objects 4 Answers
Player not affected by moving platform? 0 Answers
Movement based on collision on a custom mesh 0 Answers
How to Have Two Child Objects of One Parent Detect Collisions Between Eachother. 1 Answer
Player getting stuck in ground (3D) player has Rigidbody, and Box Collider, world is Mesh Colliders 0 Answers