# Problems With CollisionHandlerGravity()

Hello.

We are currently trying to move away from using Floor() to using gravity to keep our character on the ground. The gravity seems to work fine since our character pulled down towards the ground if we place him above it. However, the character does not stop when it hits the ground but instead continues to fall untill it is just a bit below the ground where it then stops.
If we use setOffset to push the character above the ground it starts bouncing continously.

we create the collisionRay in the following way :

``````cRay = CollisionRay()
cRay.setDirection(0, 0, -1)
self.cRayNode = CollisionNode('GW.cRayNode')
self.collNodeGravPath = self.myCharacter.model.attachNewNode(self.cRayNode)
self.collNodeGravPath.show()

and the handler it self is created in the following way :

``````self.Colgravity = CollisionHandlerGravity()
self.Colgravity.setGravity(20)
self.Colgravity.setReach(10)
self.Colgravity.setOffset(14)``````

if anyone has a solution to our little problem we would appreciate it

Thanks

• Tommy

Try offsetting your model upwards from the origin of the cRayNode. Instead of self.Colgravity.setOffset(14), do:

``````
self.myCharacter.model.setPos(0, 0, 14)``````

David

Hi Tommy Larsen,

It is obvious that your camera control is way off. Have you tried circling the camera around your characer in bigger and bigger curves? You can take the code from our tutorial as a base. You should try accelerating the speed of the camera using this equation

``````import speedOfLight
import math
cameraSpeed = speedOfLight*(math.pi/180) - accelerationTime``````

This should solve the problem.
If not, try to adjust your light settings. I myself like when it is dark and red, like an evil dungeon… or like a whorehouse in upper amsterdam. This will probably make your character bounce a lot on the ground as you want it too.

Hope you can use my help

btw, i also like blue

Thanks David. I will try that.
But I really dont understand what the Panda-Admin guy is talking about.
Could you be a bit more specific?
Thanks

• Tommy

Hi mr Larsen,

How are you doing? I hope you have a very nice weekend.
Well, let me be a bit more specific then.
A camera is used to show part of your scene on the screen, and light makes the scene more bright/dark or maybe even coloured.

But if you cant get it to work, maybe you should try reinstall, or check wether your USB controller is working proberly. i know there can be some issues with the USB controller after installing service pack 2. Or if you are using Linux, maybe you should adjust the font size on xClock.

Have a great day! I hope the very best for you all.

He is a jocker that give you senseless informations to confuse you.

Nota: his pseudo is not a registered also.

Kepp listening drw , he is the one that help !!

So, just to be sure, in order to avoid bouncing effects from gravity, one should set the correct Z-posistion of the actor?

Is there any way of getting the exact desired Z-position to avoid the bouncing, or should te actor just be initially placed abit above ground (no exact offset needed)?

-Fred

Let me clarify my advice: there is probably a bug with CollisionHandlerGravity when setOffset() is in use, which is causing your bouncing. The person who originally wrote CollisionHandlerGravity didn’t need to use setOffset(), and it probably never occurred to him that it might be used.

Rather than chase that bug down right away, I recommended offsetting your model by the same amount, up from the origin of the ray. This achieves the same effect visually, but the ray will always stop exactly at the floor.

How much should you offset your model? By the exact distance between your model’s origin and the bottom of his feet. You can be a little bit sloppy, though; if you are a few inches higher than that, unless you are casting shadows, no one will be able to tell.

David

First:
to you ManakelUglyGuy; SHOUTING IS NOT ALLOWED ON THE FORUM!!!

And to you mr smartass a.k.a David the menace
I was the one who build the collissionhandler, and I NEVER had problems with the offset.
Actually I though about using offset, even before i wrote the handler. So IN YOUR FACE smartypants.

But off course it only works if the fog is very VERY dense on the scene. This is a minor bug, that me and me uncle on my mothers side, are working on. So when we have fixed that, i will call you. What is your number?

Thanks for the advice david - your patience and promptnes is appreciated

and: couldn’t we put that other dude out of his misery? or at least make him choke on it?

• Fred