how to do this?

Started by Disastorm, June 28, 2011, 11:36:40 PM

Previous topic - Next topic

Disastorm

Hello I was wondering how I can make my main character push objects?  I made it so when he collides with a pushable object, it will move in the direction he is facing, but then when he jumps on top of it, it will move out from under him.  How can I detect that he is colliding with the top part of the object to prevent it from moving?  Does this involve getting the mesh and then the bounding box?

Thanks.

EgonOlsen

Why not simply ignore the y-vector in the movement?

Disastorm

sorry what do you mean? do you mean there is a way to ignore collisions due to y vector?  My object does not move in the y direction it moves only in the direction that the character is facing, either x or z or combination of the two, but even when my character is on top of the object the gravity keeps colliding him with the object below and it moves forward even with my character not moving.

EgonOlsen

I see...then compare the transformed center of the object with the one of the player and if the player is above the object, don't move it.

Disastorm

I was thinking of doing that, but I was thinking that wouldn't work if my player was taller than the object itself, then he would never be able to push the object because the y coord of the player's center would always be higher than y coord of the object's center.

EgonOlsen

Don't use the absolute coordinates but some delta values instead.

Disastorm

What do u mean?  You mean if the difference between the y's is greater than a certain value (which will be different for each object) then don't have the object move?

EgonOlsen

Just use some educated guess...i really depends on the level design and scene setup. It's impossible to advise a proper strategy without knowing that. But in general, i would try to find some upper bound for collisions. That may either be the absolute position of the player or it's y-distance to the object.