1
\$\begingroup\$

What do i need to keep my player model from going through environment objects like walls, trees etc?

Im trying to figure out if should use rigid bodies and the built in physics but i feel that its too difficult to predict what will happen then.

Is there an alternative that still will prevent the player from going through environment objects?

At the moment my player is a 3d model compsosed of some primitive shapes and a capsule collider.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ If you are using unity, it has built in player controller physics objects that can be used for this, as well as behavior scripts to get you started with movement as well. You normally do not want to use rigid bodies in their plain form for player physics. The reason for this, is that realistic movement on players in video games does not provide the level of responsiveness, and control that people expect. \$\endgroup\$
    – Evan
    Nov 20, 2013 at 20:30

1 Answer 1

1
\$\begingroup\$

Normally, physics simulation is done in three phases. First, in the so called broad phase, possible colliding bodies are determined. That is just to save computation time in the next step. Then, in the narrow phase, actually collisions and constraints are detected. Afterwards, they get resolved.

Implementing such a physics simulation is a big effort, which I don't advice you to take yourself. Since you used the unity tag, you may use the physics simulation integrated in that engine. Otherwise, there is a very popular open library called Bullet Physics.

If you want to implement something yourself, especially for learning purpose, you can drastically simplify things for now. For example, don't calculate triangle accurate collisions for your bodies, but just check their bounding boxes. Those can be constructed by their minimum and maximum coordinates in all directions. Or instead, you might want to treat every body as a sphere in the physics simulation, only represented by a radius.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .