how to prevent two static objects from overlapping each other.

how can i prevent two static objects from overlapping each other?

what i did- i created two objects spaceship1 and spaceship2,i created buttons to control spaceship1 and it worked perfectly,but then just for fun i created another spaceship(spaceship2) to see what will happen if i collide them both

what i saw- i expected them both to collide just like when a dynamic object collided with the static object

but instead of colliding they were overlapping each other.

Static objects do not generate collisions among themselves. At least one body has to be “dynamic”.D

Depending on how you are moving things, you could use non-physics collision detection. See:

https://coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

Rob

statics don’t collide with statics, end of story.  perhaps you intend them to be kinematic, if not dynamic?

woow,it worked,thank you for your help :slight_smile:

My two cents…

I never use static objects, partly for the reason above, unless I know for sure they are what I really want (queue much soul searching.)

Ok, I’m over-egging it, but I use what I like to call an anchor. A single, small, static object with a big density, off screen, invisible and a sensor - occasionally filtered set so it cannot collide with anything ever. Every other object I create is then a dynamic body, with optional sensor=true, and if I want them to be fixed in position I weld them to the anchor.

It works like a charm and I’ve yet to have any problems. Keep a reference to the weld on the dynamic object if you must, but if the dynamic bodies are to be removed at some point I generally don’t worry about it.

Static objects do not generate collisions among themselves. At least one body has to be “dynamic”.D

Depending on how you are moving things, you could use non-physics collision detection. See:

https://coronalabs.com/blog/2013/07/23/tutorial-non-physics-collision-detection/

Rob

statics don’t collide with statics, end of story.  perhaps you intend them to be kinematic, if not dynamic?

woow,it worked,thank you for your help :slight_smile:

My two cents…

I never use static objects, partly for the reason above, unless I know for sure they are what I really want (queue much soul searching.)

Ok, I’m over-egging it, but I use what I like to call an anchor. A single, small, static object with a big density, off screen, invisible and a sensor - occasionally filtered set so it cannot collide with anything ever. Every other object I create is then a dynamic body, with optional sensor=true, and if I want them to be fixed in position I weld them to the anchor.

It works like a charm and I’ve yet to have any problems. Keep a reference to the weld on the dynamic object if you must, but if the dynamic bodies are to be removed at some point I generally don’t worry about it.