move character with physics

Started by
4 comments, last by bzroom 14 years, 1 month ago
I have added physics to my game (made with XNA and JigLibX as physics engine) but now i want to move my character around. Currently i just have a basic game with a terrain and a few boxes spread around the field. These boxes also have physics applied to them. I also load a character in my game with physics applied to it, but my problem is, that i don't know how to make it 'walk' around. I can apply a force to my character, but this way my character will accelerate and de-accelerate when i press and release the movement keys. This is ofcourse good to simulate a car moving around, but not for normal human like characters. So i was wondering how others do it in their game. I don't want my character to slowly accelerate, i want it to move with a constant speed and when i release my keys that it stops immidiately. Anyone any suggestions???
Advertisement
Sounds to me like you need bone skinning and animation. making a system that works with the physics to animate the bones in a character is something very complicated. You could just use the physics for collision detection on the character and use skinning and animations to animate it.

------------------------------

redwoodpixel.com

My character isn't skinned atm and that's not really important right now.

My problem is that i cant/dont know how to make objects which i attached the physics body and skin to move. ( i loaded them, and they collide and everything.) ...

But movement of my character (which is just a box atm) is different with physics on it, because i have to use forces or velocity or anything like that to make it go somewhere. The problem with that is, that it has acceleration.
So it starts slow and goes faster and faster each second. I just want it to have a normal constant speed. So i was hoping that there's a trick / formula to do that with forces/velocity/mass or something like that.
Quote:Original post by vivendi
My character isn't skinned atm and that's not really important right now.

My problem is that i cant/dont know how to make objects which i attached the physics body and skin to move. ( i loaded them, and they collide and everything.) ...

But movement of my character (which is just a box atm) is different with physics on it, because i have to use forces or velocity or anything like that to make it go somewhere. The problem with that is, that it has acceleration.
So it starts slow and goes faster and faster each second. I just want it to have a normal constant speed. So i was hoping that there's a trick / formula to do that with forces/velocity/mass or something like that.


Acceleration is more realistic. Try applying a strong acceleration at the beginning that decreases very fast to 0.
http://jiglibx.wikidot.com/forum/t-195582 maybe?

[google] "JigLibX Character Controller"

This is typically an annoying problem with physics libraries. I know PhysX provides a nice character controller class that gives you more explicit control over a character capsule.

-me
Theres lots of ways to do it.

*High acceleration rates (constant acceleration)
*Interpolation (fast take off smooth arrival)
*Animation driven (you control the speed of the animation which has encoded the translation to be applied to the player)

I would lerp the intended speed, feed that into the animation, and use the extracted translation to move the character, bounded by the collision environment.

This topic is closed to new replies.

Advertisement