Velocity functions in Unity Chipmunk2d

Chipmunk2D Bindings for the Unity3D engine
Post Reply
Steve Oldmeadow
Posts: 17
Joined: Tue Jul 16, 2013 10:27 pm
Contact:

Velocity functions in Unity Chipmunk2d

Post by Steve Oldmeadow »

I was wanting to do something similar to the planet demo that ships with Chipmunk. I notice that the pure Chipmunk2D source code is setting a velocity function on the body. What is the best way to achieve the equivalent using Chipmunk2D for Unity?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Velocity functions in Unity Chipmunk2d

Post by slembcke »

Calculating and setting a force per object per frame will work OK. Though because the integration order is backwards it might not be very stable.

Integration callbacks are really the way to go to implement that. They are on the TODO list of features I'd like to have in the Unity plugin since it allows you to do things that are hard to duplicate otherwise. The implementation is going to be a little tricky I think, so I don't expect to have it done by the August 1st deadline (too many other priorities). It is something we've thought about though. ;)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Steve Oldmeadow
Posts: 17
Joined: Tue Jul 16, 2013 10:27 pm
Contact:

Re: Velocity functions in Unity Chipmunk2d

Post by Steve Oldmeadow »

No worries. Is it easy/supported to access the Unity chipmunk space from native code? I'd be quite happy writing some native plugin code in Unity that would set up the velocity callbacks and implement the callbacks natively.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Velocity functions in Unity Chipmunk2d

Post by slembcke »

Velocity integration callbacks are set per body, so you wouldn't need the space pointer. As long as the integration callback you make doesn't need to refer back to C#, it would be pretty easy to implement.

If you did want it in the native code, you can always pass the C# handle to the native function. It's a bit buried, but you can get to it via 'Chipmunk.manager._space._handle'.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests