Page 1 of 1

Question about collision detection and response

Posted: Thu Jan 18, 2007 10:36 pm
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

Posted: Thu Feb 01, 2007 12:29 am
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