Page 1 of 1

Simulating a trajectory including collisions

Posted: Wed Dec 04, 2013 3:46 pm
by ehudros
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! :)

Re: Simulating a trajectory including collisions

Posted: Wed Dec 18, 2013 12:18 pm
by slembcke
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.

Re: Simulating a trajectory including collisions

Posted: Sat Dec 28, 2013 4:51 pm
by ehudros
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.

Re: Simulating a trajectory including collisions

Posted: Tue Dec 31, 2013 4:52 pm
by slembcke
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.