Simulating a trajectory including collisions

Chipmunk2D Bindings for the Unity3D engine

Simulating a trajectory including collisions

Postby ehudros » Wed Dec 04, 2013 3:46 pm

Hi everyone,
I'm looking for a way to simulate (and afterwards render) a shot trajectory that takes collisions into account. Imagine the trajectory arcs shown in Peggle or pool games - you see how the shot is going to behave and interact with the world around it. This is relatively straightforward in an environment where you can create a clone of your physics world and step it X times every frame (or whenever you need to). However, I've yet to find a way to do something like this with the native box2d implementation of Unity - it's so encapsulated you can't even create you own world object, much less step it on your own. Is there any way Chipmunk 2d can help me if I choose it as my physics library for Unity?

Thanks! :)
ehudros
 
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm

Re: Simulating a trajectory including collisions

Postby slembcke » Wed Dec 18, 2013 12:18 pm

Not in a practical way no. The Unity way is to encapsulate things very heavily into components that can't be used outside of the scene graph. Raycasts would be a much simpler solution if you can get away with point sized projectiles.

It *is* possible if you want to poke around at the PInvoke, but this might end up being a huge amount of work.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Simulating a trajectory including collisions

Postby ehudros » Sat Dec 28, 2013 4:51 pm

Raycasting is a poor choice in my case I'm afraid. Theoretically, would it have been possible to expose the step and Chipmunk world object for developers to use as they see fit? I understand that that's not very "Unity like", but the way I see it the more power developers have the better.
ehudros
 
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm

Re: Simulating a trajectory including collisions

Postby slembcke » Tue Dec 31, 2013 4:52 pm

Well that's what I meant with the PInvoke comment. Technically almost all of Chipmunk is exposed at the C API level. It's not easy to use though. You are basically writing C style code in C# and then adding a bunch of extra code to deal with crossing the language barrier.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Chipmunk2D for Unity

Who is online

Users browsing this forum: No registered users and 1 guest

cron