Sign in to follow this  

physics and your character

This topic is 3457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a third person game. The problem is that the physics part isn't working too well. I am using Newton. When I make the character jump, it doesn't jump high enough and I'm not able to fix it. When it jumps and hits the floor, it jumps a little like a ball. Sometimes, the character walks through walls, specially when moving quickly. Character control is NOT EASY! How to figure out if something heavy has fallen on your character? How to know if your character has been hit by a knife? How do games like HL2, Doom3 and many other games do it? Is there some library that can help?

Share this post


Link to post
Share on other sites
You will need to be more specific about exactly what you are doing if you want useful answers. eg. You must be doing something specific to make the character jump, so making it jump higher will be a case of modifying that, but what that would be, I have no idea, without seeing your code or algorithm.

Sometimes, the character walks through walls, specially when moving quickly - this is probably because you are not checking the physics often enough.

How to know if your character has been hit by a knife? You see if the knife and your character now occupy the same space. If so, you've been hit.

How to figure out if something heavy has fallen on your character? You look to see if anything is touching your character, you see if it's heavy, and you see if it was falling. All quite simple.

Share this post


Link to post
Share on other sites
Like my last line says "Is there some library that can help?" but if no one knows I guess I will have to ask if there is anything wrong with my code and show some code.

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
Like my last line says "Is there some library that can help?" but if no one knows I guess I will have to ask if there is anything wrong with my code and show some code.

Yeah, it's called Newton Archimedia's character control joint ;)

Anyways, answers to all of your points:
- for jumping, just use NewtonBodyAddImpulse()
- to stop the bouncing, set the restitution of the material to 0 (NewtonMaterialSetContactRestitution()) when the player is colliding with anything (using the material contact process callback)
- if your character is walking through walls, then you must be using velocity to control him. Don't do that in 1.53! Get the current beta of Newton Archimedia (PM Julio on the NGD forums for it), and then feel free to do it. Or, even better, use NewtonBodyCalculateInverseDynamicsForce() instead. Yet, even better, just use the provided character control joint in Newton Archimedia [wink].
Quote:
Character control is NOT EASY!

We know, thus, the ... character control joint in Newton Archimedia [grin].
- to figure out if something heavy has falling or pushed your character, just override the material contact process callback (as I mentioned above) and check the contact velocity using NewtonMaterialGetContactSpeed() and NewtonMaterialGetContactPositionAndNormal().
- the knife is completely on your side, unless you're completely and accurately simulating the physical swinging motion of a knife

Share this post


Link to post
Share on other sites
Thanks agi_shi,

I am using Newton 1.53. I have a wrapper function so if I want it to jump, I call SetForce which sets some force direction value. Eventually the force and torque callback function gets called and finally NewtonBodySetForce() gets called.
I could give NewtonBodyAddImpulse() a try.

Quote:
if your character is walking through walls, then you must be using velocity to control him

No, I am using the same method as for jumping. So, NewtonBodySetForce() gets called. Some other functions as well : NewtonConvexHullModifierSetMatrix(), NewtonBodyGetOmega(), NewtonBodySetTorque(), NewtonUpVectorSetPin().

I am not going for accuracy. The character for now is a ellipsoid. I got the idea from one of the demoes in the Newton SDK.

If there is some code that can demontrate these things, that would be great. Some of the demoes on the Newton site don't come with source unfortunately.

Share this post


Link to post
Share on other sites

This topic is 3457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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