hi im wondering how would this lets say we have a block (Object-1) that is motionless in mid-air and then we have an shooter (Object-2) that is shooting at it and we want Object-1 to react how it would naturally once it was hit (It would then not become static and turn dynamic) Ie. if Object-1 gets hit from the bottom by Object-2 Object-1 would no longer be motionless and it would go up for a bit then gravity would push it back down... or if it were to get hit from the bottom right it would go up and to the left.... or if it were hit by another block hat is falling it would fall down also.
i realized that ti would have to use a pre collision callback function on the object1/2 collision that would replace static object 1 with dynamic object 1. i.e. add object 1's body to the space at that point. I'm pretty sure that would work. but i have no clue how to do this
If anyone could help me with this it would be greatly appreciated.
Pre collision callback HELP
-
- Posts: 2
- Joined: Mon Feb 08, 2010 6:38 pm
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Pre collision callback HELP
It's pretty simple actually. Create the body as normal (give it a normal mass), but do not add it to the space. Add the shape to the space as a static shape. Create a collision callback that does two things. 1) Add the body to space. 2) Remove the static shape from the space and re-add it as a normal shape.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 14 guests