-
December 4th, 2011, 05:32 PM
#1
How to walk on terrain and not go through walls ?
Hi, please help me implement simple character controller based on basic physics. I read hundreds of tutorials and articles, but didn't find answer, explanation with short code. I can't handle two "basic" things in moving around 3D world:
1.) How can I make my character (it can be a first person camera, a cube or any other mesh) doesn't go through walls ? I'm moving forward in my 3D world -> there is a wall or any other object (chest, car, building) in front of me -> so I can't go, I have to stop! How to do this ???
2.) How can I make my character goes on terrain that is not flat, but has slopes ? My object must be stuck to a ground. I'm moving forward and if a terrain rises, so my object also moves up (Y axis). I'm walking -> there is no ground/floor under my legs -> I'm falling down (Y axis) as long as there is some kind of object (terrain, floor, any other plane) under my legs. How to do this ???
How is it done in real 3D games ?
Please help!
-
December 6th, 2011, 05:56 AM
#2
Re: How to walk on terrain and not go through walls ?
Detecting collisions is time consuming, but it is not very difficult.
You simply look if there is a wall in front of you and look at the altitude of the ground below your feet. You might also look if there is another character in your way.
How do you "look" at things?
If you have a map with every obstacle, then this is quite easy.
Otherwise, you need to use sensors to feel if there are obstacles or not.
If you have one camera, you cannot know the distance from a wall unless the wall has some painted patterns whose size you already know.
If you have two cameras, you can compute the distance with the parallaxe and a visual reference on the wall.
Or you can have an arm with a piston and a string. If the piston touches something, then the string is compressed, and the length of the arm is shortened. You can detect the length of the arm with diodes or piezoelectric sensors.
-
December 24th, 2011, 06:28 AM
#3
Re: How to walk on terrain and not go through walls ?
Rate my post if i it was useful!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|