Problem with Physic Objects in Game Rotating Slightly

Hi guys, this is my first post on these forums so be easy on me :slight_smile:

I am working on a Role Playing Game that uses a tiled map with the addition of monsters which rely on physics to determine projectile weapon impacts etc …

Somewhat randomly BUT it could be when monsters collide OR change direction (I have not isolated it exactly) the monster object appears to rotate. It did not do this before I added physics to the game and I have set the addBody method using a friction and bounch and density of 0 which to my knowledge should mean they do not rotate like this.

Below you should see what I mean. The wolf looking critter with the green bar below is actually several degrees rotated and should not look like this.

Example of my addBody code …

physics.addBody( monsters[m], { density = 0, friction = 0, bounce = 0 } )

After a while the monsters become so badly rotated that it looks horrendous.

Any ideas?

I do use onCollision to detect when a particle weapon impacts but no where do I alter or modify rotations.

Thanks,

Daniel [import]uid: 81523 topic_id: 37082 reply_id: 67082[/import]

Hi Daniel,

Have you tried adding “.isFixedRotation = true” to the monsters? That should stop them from being able to rotate. If you’ve already tried that them i’m not too sure what the problem is…
[import]uid: 69826 topic_id: 37082 reply_id: 145315[/import]

Hi there, welcome to the forums!

Try setting the [lua]isFixedRotation[/lua] property of your physics objects to [lua]true[/lua]. (See http://docs.coronalabs.com/api/type/Body/isFixedRotation.html) This will prevent your objects from rotating even if they are hit in such a way that a normal object would rotate.

Hope this helps!

  • Andrew [import]uid: 109711 topic_id: 37082 reply_id: 145316[/import]

That did it … thanks! So simple yet I spaced over that in the docs.

Thanks for the quick response! [import]uid: 81523 topic_id: 37082 reply_id: 145324[/import]

Hi Daniel,

Have you tried adding “.isFixedRotation = true” to the monsters? That should stop them from being able to rotate. If you’ve already tried that them i’m not too sure what the problem is…
[import]uid: 69826 topic_id: 37082 reply_id: 145315[/import]

Hi there, welcome to the forums!

Try setting the [lua]isFixedRotation[/lua] property of your physics objects to [lua]true[/lua]. (See http://docs.coronalabs.com/api/type/Body/isFixedRotation.html) This will prevent your objects from rotating even if they are hit in such a way that a normal object would rotate.

Hope this helps!

  • Andrew [import]uid: 109711 topic_id: 37082 reply_id: 145316[/import]

That did it … thanks! So simple yet I spaced over that in the docs.

Thanks for the quick response! [import]uid: 81523 topic_id: 37082 reply_id: 145324[/import]