Sign in to follow this  
  • entries
    235
  • comments
    509
  • views
    172053

Rolling Along

Sign in to follow this  

96 views

Let's Get Physical

I am working on improving the physics. I have rewritten it several times, and am finally happy with the code, and also
making good progress, and cleaning up quite a bit as well.

I have a Collidable interface that handles most of the interactions, with virtual overloaded methods given to the children to do capsule, sphere, or tri-specific tasks.

Just now I got both the character movement and characters bumping into things working well. Also, I just fixed a bug w/ object vs object collision, so that is working, now, too.

I even have rotation in there, but it's not using the data for display yet.

I definitely end up treating the sentient beings differently than the objects. For instance, sentient beings don't receive
collision momentum from other objects, they just receive their contact info so they can move out of collision. They can,
however, impart momentum onto other things, so as your character moves across the ground and kicks a skull, it will skitter
out of the way.

Originally, I was using real-world masses in Kg, and using the relative mass of the objects to handle momentum impulses.
I had to quickly remove this, however, b/c large differences in mass just create very unrealistic behavior.

For instance, if a 90 Kg character bumped into a .2 Kg skull, the skull would go so fast it would leave the level. I
added back the velocity cap to avoid this, but still it looked incredibly unrealistic the way it shot away from the player.

Now part of the problem is the very simple model I'm using. For instance, I effectively treat each encounter as if each object
is imparting its entire mass against the other object at the entire relative velocity of the two objects.

If you were just walking and brushed something, only part of the momentum of your foot and leg would really effect the skull.
Only if you really focused and gave it a good solid kick could you get it to really shoot off.

Maybe I can add mass back in, but assume that sentient beings only have 2% of their mass to impart to level objects. If there
were a separate mode for pushing or pulling an object, in that case more of the character's mass would be applied.

For now, though, it feels good ignoring mass completely, so I'll leave it that way for simplicity's sake.

One other tweak for sentient objects was to cancel any left-over upward velocity they may have each frame. In my physics
test level, there are some peaks and ramps, and if you ran up the ramp, you really flew over a large part of the room. I guess it's like a running jump. It's not clear if we are even including jumping in the game, and it seemed easy to walk off a peak and go farther than you intended, so I clamped the upward velocity for sentient beings, and that seems to work much better. You can still get a little air if you are coming down, but at least it's no longer like a ski slope.

Update

Ok, now the rotation is rendered properly. I've got the rolling working for spheres, when they hit something, they bounce and spin. Last night the boulders were rolling again, but the skulls were rolling backwards for some reason, like they had backspin. I'm not really modelling real rolling or spinning, but rather, just taking the object's linear velocity and using it to derive the angular velocity. The rotation axis comes from the cross product of the velocity and the collision point - center of mass.

Capsules almost work, but they don't 'fall over' like you expect. I think this is because I am not taking into account the inertia tensor, which to my undertanding, summarizes the mass distribution of the shape over its volume. For a capsule, the mass is distributed vertically, which should cause it to tip over if its on its top or bottom.

Here is a shot of 4 physical objects, which can knock into each other and roll around ( except for the player which doesn't roll ) :


Later today I'll work on getting the specified object size respected in the level editor.
Sign in to follow this  


1 Comment


Recommended Comments

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