Making objects behave like kinematic but with collision?

Hi,

I have two objects that need to be able to collide with eachother, or for LUA to know if they collide, but I don’t want the objects spinning and turning as it does when it’s set to dynamic (physics body).

I want the item to behave like a kinematic object that is being dragged i.e. it goes up, down, left and right and over the other object but that it also detects collisions.

Here it says:

http://developer.coronalabs.com/content/game-edition-physics-bodies

  • static bodies don’t move, and don’t interact with each other; examples of static objects would include the ground, or the walls of a pinball machine.
  • dynamic bodies are affected by gravity and collisions with the other body types.
  • kinematic objects are like static bodies, but they can be moved and are affected by forces but not by gravity, so you should generally set draggable objects to “kinematic”, at least for the duration of the drag event

 

So how do I do if I want to kinematic bodies to detect a collision?

 

Best regards,

Tomas

Try making them dynamic, but set their gravityScale property to 0 (so they don’t experience gravity) and set their isFixedRotation property to true (so they don’t rotate when torque is applied).

  • Andrew

Hi Andres,

thanks again for your help.

Wouldn’t this make the object to be able to interact with eachother i.e. if I move the letter image I can move the other objects as they are dynamic (and not “just kinematic”)?

Best regards,

Tomas

Hi Tomas,

It’s possible I’m not understanding correctly what you’re trying to accomplish.  I also don’t know what you’re referring to be “letter image”.

If you want to know when an object is colliding with another object, but not have it actually interact with the other object, then you can make it a ‘sensor’ by setting its isSensor property to true.

  • Andrew

Thank you very much Andres, that solved my problem!

Just to explain what I wanted to do and what Andrews solution did:

Look at this picture http://i39.tinypic.com/24vk7zl.png the idea is that the image letters (A, B and C) should be able to be dragged up to the empty letter boxes (the ones above) AND to detect collision but not interact (not move each others images because of the bodies) which is what setting isSentos = true does

Thanks again Andrew!

Best regards,

Tomas

Try making them dynamic, but set their gravityScale property to 0 (so they don’t experience gravity) and set their isFixedRotation property to true (so they don’t rotate when torque is applied).

  • Andrew

Hi Andres,

thanks again for your help.

Wouldn’t this make the object to be able to interact with eachother i.e. if I move the letter image I can move the other objects as they are dynamic (and not “just kinematic”)?

Best regards,

Tomas

Hi Tomas,

It’s possible I’m not understanding correctly what you’re trying to accomplish.  I also don’t know what you’re referring to be “letter image”.

If you want to know when an object is colliding with another object, but not have it actually interact with the other object, then you can make it a ‘sensor’ by setting its isSensor property to true.

  • Andrew

Thank you very much Andres, that solved my problem!

Just to explain what I wanted to do and what Andrews solution did:

Look at this picture http://i39.tinypic.com/24vk7zl.png the idea is that the image letters (A, B and C) should be able to be dragged up to the empty letter boxes (the ones above) AND to detect collision but not interact (not move each others images because of the bodies) which is what setting isSentos = true does

Thanks again Andrew!

Best regards,

Tomas