Sign in to follow this  
patrrr

Physics behaving badly

Recommended Posts

I'm using ODE for my FPS-like game, and I'm having some quality problems: 1. Walking up stairs/ramps is really slow. What I want: same speed up as down a stairway/ramp 2. The player slides down ramps, expected: no sliding 3. The motion is very slow when I press the player against a high friction wall while standing on a floor with low friction, expected: no friction against walls 4. Pressing the forward button while on a flat surface doesn't always make the player move in the correct direction, sometimes it's off by a small (noticeable) bit. I think it's because of how the friction is applied or something like that. The physical representation of my player is a capped cylinder which I kill all torque on and keep up-right, the way I represent the level doesn't matter in this case (I've tried trimeshes, boxes, etc.) I move the player/capped cylinder by adding a force in the direction I want it to go. I know that many of these problems can be solved by adding a ray geom where the legs should be, I tried it for the stairs and if I remember correctly It worked pretty well. I decided not to use the ray though because it felt like a hovercraft, the player simply floated above all the objects on the ground. When I jump on a box, I want the box to react. The box should be able to have an affect on the player. Question #2 could be solved by adding friction, but then it would be even slower when walking up the ramp. So my question is; how can I fix these problems and should I go back to the ray (how can I solve the hovering)? Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by patrrr
I'm using ODE for my FPS-like game, and I'm having some quality problems:

1. Walking up stairs/ramps is really slow. What I want: same speed up as down a stairway/ramp
If you apply the same force to go up and to go down, are you perhaps adding gravity in one case and subtracting it on the other? You should compensate for friction and gravity to get the desired speed.
Quote:

2. The player slides down ramps, expected: no sliding
As you already realized, friction is the cure; it shuldn't be a problem.[quote]
3. The motion is very slow when I press the player against a high friction wall while standing on a floor with low friction, expected: no friction against walls
[quote]Are you sure you aren't simply canceling the motion force against the wall's reaction?[quote]
4. Pressing the forward button while on a flat surface doesn't always make the player move in the correct direction, sometimes it's off by a small (noticeable) bit. I think it's because of how the friction is applied or something like that.
[quote]So tell us how the friction is applied; the symptom suggests that at least one of the forces you apply has a wrong direction.

Share this post


Link to post
Share on other sites
Thanks for your reply!

Quote:
Original post by LorenzoGatti
If you apply the same force to go up and to go down, are you perhaps adding gravity in one case and subtracting it on the other? You should compensate for friction and gravity to get the desired speed.


I add the force on the world horizontal plane, which means that when I walk up something, some of that force goes into the ground, and when I walk down, the force goes out in the air.
To fix this I would have to check the direction of the ground, but the thing is, there is no difference between ground and walls to the engine, it's all just geoms.
So how do I know that I'm standing on the ground? I tried by taking the dot product of the normal from the collision (dContact.geom.normal) with the inverted up-vector (0, -1, 0) and checking whether it was in a range, but it doesn't work in some cases, namely when standing on boxes and other objects. But it doesn't detect walls as ground, which is good.

But it would still be faster going down than up -- due to gravity, just as you said. I have no idea how to compensate for that. And there's still a problem with stairs.


Quote:
Are you sure you aren't simply canceling the motion force against the wall's reaction?

Yes, I'm moving at an angle towards the wall, and thus an increase of wall friction leads to a slower total movement. Set the friction to the same as the ground and it's fine.
If I managed to correctly detect which collisions are against the ground I could simply null the friction added by non-ground geoms, but I think there can be times when this looks bad.


Quote:
So tell us how the friction is applied; the symptom suggests that at least one of the forces you apply has a wrong direction.


Friction is applied by calculating a friction coefficient for each colliding pair of geoms (geom1's friction * geom2's friction) which is then put in the ".surface.mu"-field of a dContact object which then goes into the dJointCreateContact function.
I set ".surface.mode" to 0.

The force vector is probably all right; if I add it as an offset to the player's position instead of an impulse then it's correct. Though I multiply the vector by ~30000.0, otherwise the force is just too low. (I guess I should use the force-to-impulse-converter, but I don't think that'd make a difference here)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this