Question about collision detection and response

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
shagdawg
Posts: 9
Joined: Mon Jan 08, 2007 11:36 pm

Question about collision detection and response

Post by shagdawg »

So I have all the collisoins set up on the main character and they can run around in a couple of diffrent test levels that I am working on setting up.

One of the test levels so far is just a ITerrainSceneNode, anyhow my character is able to run up really steep hills. Granted they run up it pretty slowely this is not the behavior that I want because I want the player to have to weave around hills/mountains.

So I have an idea to fix it but not sure if it will work due to when the collision detection and response happen.

Does the detection and response happen during a set postion call, or does it happen some time later. (can somone verify)

What I was thinking was somthing like this
Old postion = node->get postion();
node->setPostion(newPostion);
???????*collision and response get updated here???????
currentPostion = node->getPostion();
DeltaY = oldPostion.Y - newPosition.Y
if(DeltaY > x) node->setPostion(oldPostion);

So if I can't do what I have listed above do you guys have any othe suggestions that I could?

Sorry for not posting my current code, I am at work right now I can get it put up tonight if needed
raven_coda
Posts: 89
Joined: Thu Aug 17, 2006 8:11 pm
Location: Salt Lake City, UT, USA
Contact:

Post by raven_coda »

The collision detection is an Animator to the node so it runs during onPostRender. However, OnPostRender requires you to pass it the amount of time that has passed since it's last call to do the physics correctly. Most likely you won't know this thus you might want to try one or both of the follow.

Use a higher gravity so it's harder to climb things
or use a Larger slidingspeed

the slidingspeed var is not exactly what it seems...

Here's how it's used.
If the amount the distance the node moves is < slidingspeed then it doesn't move the node at all. So if you character is moving VERY slow up the hill increasing this will stop him from moving up the hill at all.

If that doesn't work then you could use your idea and have the smgr->drawall(); line in the middle but I'm not sure how well this will work because it might be a little jittery
Definition of an Upgrade: Take old bugs out, put new ones in.
Post Reply