Best practice for game movement

Official forum for the Chipmunk2D Physics Library.
Post Reply
HunterZolomon
Posts: 4
Joined: Fri Jun 13, 2014 7:15 am
Contact:

Best practice for game movement

Post by HunterZolomon »

Hi all, I just joined and I'm new here and to Chipmunk. I'm currently working on a little game project where I want to use Chipmunk.js + Pixi.js for a WebGL rendered javascript game. So far it's working great, Chipmunk has been very easy to implement. I have a few noob questions though:

1. Is there any best practice when it comes to movement in games? I'm not using gravity but I need to have some kind of friction or dampening to the players character in the Chipmunk space. What I need to do is apply a motion vector (with speed constraints) to the player body and have that fall off once the user lets go of a directional pad. I can think of a few ways, but this is the first time I use a proper physics engine so I'd appreciate if anyone could give me any pointers to what is best practice when atttempting this kind of functionality. Applyforce with some kind of deceleration?

2. I'm building the game world with tiles constructed from segments. Sometimes the segments connect from tile to tile to form one long line and when the body is touching that line while moving it will sometimes "bump" where the segments connect. I know this is a common physics engine issue, but is there a good workaround in Chipmunk?
I currently use the segment radius function and it helps quite a bit. But since you need to compensate for the radius padding the solution doesn't feel very elegant. Neither do I want to go through the world (it's quite large) and replace the segments that align with one segment since performance tweaks will be a bit more tricky when segments are shared between tiles. Any thoughts?

Lastly, thank you for a great physics engine! Even though I'm just getting into Chipmunk it feels like a solid choice.
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Best practice for game movement

Post by maximile »

Surface velocity tends to be handy for player movement. You can see how we did it in a small project here:

https://github.com/maximile/Your-Story/ ... haracter.m

(Look at playerUpdateVelocity. In action: https://www.youtube.com/watch?v=AHaOfBp-raY )

Unfortunately, I think merging the collision shapes is the only way to go for eliminating the bumps. This might be sorted in a future release, see here: http://howlingmoonsoftware.com/wordpres ... pmunk-6-2/
HunterZolomon
Posts: 4
Joined: Fri Jun 13, 2014 7:15 am
Contact:

Re: Best practice for game movement

Post by HunterZolomon »

Most appreciated, thanks! I'll have a look at your links and see what I can discover :)
Post Reply

Who is online

Users browsing this forum: Heise IT-Markt [Crawler] and 7 guests