1
votes

I'm working on a game in which I have a objects that are "static" on screen so they don't react to gravity and at the same time, objects can fall from the top and collide with them. That part is all good. However, I want the collision to result in the static objects rotating based off speed/angle of the collision but not respond in any other way like flying off the screen.

Is there a way to stop the static objects bouncing away and instead just rotate in position?

1

1 Answers

1
votes

Your static objects still have collision events. So you can catch those events and rotate you objects by yourself.

The other way is: use dynamic body. But when add body to them set bounce to 0; so they won't bounce. And about Gravity, you can set gravityScale to 0 to make them don't react to gravity


Remember: static objects can't move or rotate by physics. You must do it yourself. And you can stop dynamic objects from bouncing or falling with gravity by setting 'gravityScale' and 'bounce' attributes

And more, if you don't want it to get pushed, catch collision event with right phase ( belongs to yours situation ) and set it linearVelocity to (0,0)

I haven't tried it before, but maybe you can make it a dynamic object but link to a static object ( likes a wheel link to a post ). So it can't move but still rotate when collision

P/S: I did a test and it worked. Make your objects like dynamic-balls and link them to static objects. They now can't move but rotate when collision.