Display Group / Physics Problem

Hello,

I have been working on a project and found that for whatever reason, when I moved a display group containing physics objects, things would still fire collision events at the same positions even though it moved.  So, if I have a ball collide with the ground at a y of 400, the ball bounces back up, and the display group containing the ground will move down to simulate progression.  However, the ball continues colliding with empty space at the literal y position of 400 while the ground appears to be at, say, 450 or so.  I tried setting setDrawMode to debug in physics, but it shows no more than what I’ve already seen… that nothing is there where the ball is colliding, and nothing seems out of place.

This display group, however, isn’t the direct self.view from the storyboard api, but is a group inserted into self.view.  When I tried using self.view directly, it worked perfectly… the ball first bounces off at 400, ground moves to 450, ball then bounces at 450.  Is there some kind of workaround for this?  Is this even a known issue?  

Came across this:  http://forums.coronalabs.com/topic/37667-moving-a-display-group-wont-move-the-physics/

Seems kind of strange that, even though in debug mode, it shows the physics objects moving, yet the physics itself remains permanently attached to those positions despite the display group moving?  What’s even the point of debug mode, then, if not to truly show where the physics engine is detecting shapes?  

Is there no way of relying on the physics engine for this?

Hi @elsoqo,

This is one drawback of the debug mode and always has been. Debug is reliable as long as you retain groups in the same coordinate space with each other, but otherwise, you’ll see issues. We have investigated fixing this, but the potential for undesired side-effects on the overall physics engine took it off the table for consideration.

Remember that in terms of collisions, you should never move groups around independently of each other if you want objects between those groups to potentially collide.

Best regards,

Brent

Then, whats the best option if i wanna move a pair of different physics objects at the same time?

Cause all the options I thought are reducing my performance a lot, and my game is lagging in some devices :’(

 

Hi @bigi.studios,

How are you moving them? By physical properties like setting velocity? By a touch-drag? By a Runtime enterFrame? The best solution probably depends on this.

Best regards,

Brent

Came across this:  http://forums.coronalabs.com/topic/37667-moving-a-display-group-wont-move-the-physics/

Seems kind of strange that, even though in debug mode, it shows the physics objects moving, yet the physics itself remains permanently attached to those positions despite the display group moving?  What’s even the point of debug mode, then, if not to truly show where the physics engine is detecting shapes?  

Is there no way of relying on the physics engine for this?

Hi @elsoqo,

This is one drawback of the debug mode and always has been. Debug is reliable as long as you retain groups in the same coordinate space with each other, but otherwise, you’ll see issues. We have investigated fixing this, but the potential for undesired side-effects on the overall physics engine took it off the table for consideration.

Remember that in terms of collisions, you should never move groups around independently of each other if you want objects between those groups to potentially collide.

Best regards,

Brent

Sorry for taking so long to reply… (Christmas holidays) haha :slight_smile:

I’m moving by a touch-drag

I was using at first time, the non-physics collision tutorial.

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

But the problem is that one of the objects I wanna collide, is all time rotating (By enterFrame) and, its impossible to have an accurate collision.

I dont know what to do… :’(

I only can move them individually each time I touch/drag?

Hi @bigi.studios,

If you want to touch-drag more than one physics object at a time, I suggest that you still do it via a Runtime move+reposition, just applied to both objects (and don’t be tempted to put both objects in a group and move the group, as that will complicate issues).

And then, rely on physics collisions, not the non-physics method.

Hope this helps,

Brent

Then, whats the best option if i wanna move a pair of different physics objects at the same time?

Cause all the options I thought are reducing my performance a lot, and my game is lagging in some devices :’(

 

This weekend I will try both solutions, is anyway to know the RAM/memory that will consume both of this?

You dont think that if I do it via Runtime, and i’m not moving anything, i wont be wasting memory?

Thanks for your dedication with you answers Brent,

Adrian

Hi @bigi.studios,

How are you moving them? By physical properties like setting velocity? By a touch-drag? By a Runtime enterFrame? The best solution probably depends on this.

Best regards,

Brent

Hi Adrian,

If possible, seek a method to only start the Runtime (drag) listener when needed, and then turn it off when you’re not using it. For example, on touch of the object(s), start it up, then when touch is released, stop it again. This way, it won’t be running constantly while the app is effectively doing nothing. But even so, I doubt you’d notice any performance hit either way… it’s just “best practice” to stop/pause Runtime listeners that you don’t need running.

Brent

Sorry for taking so long to reply… (Christmas holidays) haha :slight_smile:

I’m moving by a touch-drag

I was using at first time, the non-physics collision tutorial.

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

But the problem is that one of the objects I wanna collide, is all time rotating (By enterFrame) and, its impossible to have an accurate collision.

I dont know what to do… :’(

I only can move them individually each time I touch/drag?

Hi @bigi.studios,

If you want to touch-drag more than one physics object at a time, I suggest that you still do it via a Runtime move+reposition, just applied to both objects (and don’t be tempted to put both objects in a group and move the group, as that will complicate issues).

And then, rely on physics collisions, not the non-physics method.

Hope this helps,

Brent

This weekend I will try both solutions, is anyway to know the RAM/memory that will consume both of this?

You dont think that if I do it via Runtime, and i’m not moving anything, i wont be wasting memory?

Thanks for your dedication with you answers Brent,

Adrian

Hi Adrian,

If possible, seek a method to only start the Runtime (drag) listener when needed, and then turn it off when you’re not using it. For example, on touch of the object(s), start it up, then when touch is released, stop it again. This way, it won’t be running constantly while the app is effectively doing nothing. But even so, I doubt you’d notice any performance hit either way… it’s just “best practice” to stop/pause Runtime listeners that you don’t need running.

Brent