Rotate object on collision

Hi, I have problem with rotating “bullet” on collision…
Im getting this error:
“ERROR: Cannot rotate an object before collision is resolved.”

Pre and post collision does not works for me :confused:

I found exactly same problem here :
http://developer.anscamobile.com/forum/2011/09/11/how-rotate-object-collision-event

And they solved it through timer, it will probably work, but only for 1 “bullet”, but I can spawn multiple “bullets” at one time and here is problem… How can I define what bullet to rotate through timer after collision?

For spawning bullets Im using this tutorial from ansca:
http://blog.anscamobile.com/2011/09/how-to-spawn-objects-—-the-right-way/

Thanks for any help ;). [import]uid: 59968 topic_id: 17433 reply_id: 317433[/import]

Not sure what you are trying to accomplish exactly. Perhaps you’re fighting the physics engine? if the object is rotating as the result of a bullet striking it (or other way around), then make sure the angular velocity and mass for each object is set correctly.

Also during a collision, you can get the ID of each object involved in the collision. The object ID could be saved and handled in the right timeframe.

-David [import]uid: 96411 topic_id: 17433 reply_id: 66035[/import]

You are understand right, I need to rotate bullet on collision to right direction… I have function how to do this, but I cant apply it to the right bullet …

How can I save id of bullet during collision? And what if 2 bullets will collide in the same time?

Thanks. [import]uid: 59968 topic_id: 17433 reply_id: 66044[/import]

Try wrapping everything into a timer, even with just a 1ms delay. Sometimes that helps when you need to wait for an event to be resolved. [import]uid: 52430 topic_id: 17433 reply_id: 66136[/import]

What Jon said. You need to delay the execution of the rotation by even 1ms as box2d can’t manipulate things whilst it is doing a calculation at the exact same time. The unnoticeable delay solves this issue :slight_smile: [import]uid: 84637 topic_id: 17433 reply_id: 66360[/import]

Im not sure if I understand right. Still can’t get it work :(. Can you post some example piece of code?
Thanks. [import]uid: 59968 topic_id: 17433 reply_id: 69860[/import]