Hello,
I'm working on an action game in the top-down perpective. A small tech video can be found here: http://solidcore.se/splitinput.avi
Now that video is without chipmunk. I've successfully made some chipmunk tests in my engine so its integrated and up and running. Now I want to make that character "physicallized" by moving a circle body around so he can collide with stuff. I'd like to discuss how to handle the physics the best way here and get input from you so I know better what I'm getting into.
Here's what I think. I need 3 things: a force to apply for movement, a rotation to apply for direction and some friction to counteract the movement and stop him when I release my movement buttons.
For movement, should I use applyforce/resetforces every frame or a small impulse as I hold the key?
For rotation, should I have a target angle set by my crosshair and make the character apply rotation until he reaches that angle? Maybe rotation isn't necessary as along as the image is rotated.. what do you think?
For friction, should I somehow apply a reverse force based on the speed in the direction he's moving? Where, how?
Any ideas, tips etc I should think about when using chipmunk for this? Which functions should I look up?
Thoughts on simulating a top-down character
-
- Posts: 12
- Joined: Sat Sep 27, 2008 3:14 am
- Contact:
-
- Posts: 12
- Joined: Sat Sep 27, 2008 3:14 am
- Contact:
Re: Thoughts on simulating a top-down character
okay a shorter question then.. For a top-down friction calculation would you suggest applyimpulse or force? And how would you best go around stopping the rotation with friction? I now decrease it depending on its angular velocity.. it works but it feels crude..
EDIT: Basing torque off angular velocity was of course the answer.
It now works pretty good with applyimpulse. here's a video: http://solidcore.se/physicalplayer.avi
Code: Select all
SCFVector2 vVelocity(_pBody->v.x, _pBody->v.y);
SCFVector2 vFriction = -vVelocity * vVelocity.Length() * 20.0f * frictionValue;
_pBody->t += -_pBody->w * 10.f * frictionValue;
cpBodyApplyForce(_pBody, cpv(vFriction.x, vFriction.y), cpv(0, 0));
It now works pretty good with applyimpulse. here's a video: http://solidcore.se/physicalplayer.avi
Who is online
Users browsing this forum: Bing [Bot] and 9 guests