Has anyone successfully used physics bodies with the Perspective Virtual Camera System? I’ve been trying to use both along with each other, but the physics bodies don’t anchor with the display objects they are tied to.
Hi @jhow,
Can you clarify “don’t anchor with the display objects they are tied to”? Do you mean the “hybrid” draw mode for physics bodies? Clearly, physics bodies remain associated/tied to the object they’re on… that rule can’t be broken. What you might be seeing is related to the draw mode.
Best regards,
Brent
Hi Brent,
Can you clarify “don’t anchor with the display objects they are tied to”?
The physics bodies are not in the position that they should be (as if they are not attached to their respective display objects). If I move my display object that is the focus of the scene, all the environmental objects compensate in the opposite direction. But the physics bodies of those environmental objects stay put and don’t move with their respective display objects.
In the correct scenario, for all the display objects that move on screen, their respective physics bodies (collision boxes in hybrid mode) would move with them (ie. they are anchored together).
Do you mean the “hybrid” draw mode for physics bodies?
Yes. I am doing my testing in “hybrid” mode so I can see where my physics bodies are with respect to their associated display object.
Clearly, physics bodies remain associated/tied to the object they’re on… that rule can’t be broken.
Yes, the physics bodies (ie. collision boxes in hybrid mode) are present and seen. But they are not moving with their respective display objects. In other words, when my objects on screen are in motion, their physics bodies (represented by transparent boxes in hybrid mode) are not moving with them.
Is this issue happening because maybe the Perspective Virtual Camera System is incompatible with Corona’s physics?
There shouldn’t be a problem with the compatibility, insomuch as the Perspective library doesn’t do anything different for physics objects than it would for simple objects. Your best bet is to confirm that the physics bodies are interacting abnormally, rather than just the hybrid filter showing that they aren’t visually performing as you might expect. I’ve run into some situations where the hybrid overlay is giving me false info; the bodies are doing their thing, but it appears as though their boundaries are all over the place. Seems like the hybrid filter is more of a guideline than a rule
To clarify, this goes back to what we recommend you never do with the physics engine, and what we advise in the docs and many forum posts over the years: never move display groups containing physics objects independently of other groups. That will break collisions. You need to move the entire physics “world” in lock step if you want to use a world-camera style system.
Personally, I haven’t used the Perspective library enough to know if it’s obeying this rule of thumb. If I recall, Perspective handles multiple layers of parallax scrolling at different rates, so if you put physics objects in different layers moving at different speeds, but you expect them to interact/collide with each other “between layers”, then you’ll face issues.
Also, note that we made a noticeable change to the hybrid draw system in a daily build since the last public release. Since forever, the hybrid views would not move in accordance with a shifted display group. This was a known bug. We fixed that and now hybrid view should actually be more accurate. However, I think I’d have to see your code to see what is not working as you expect it… if you can wrap up a small sample, I can take a look.
Best regards,
Brent
@Alex@Panc and @Brent Sorrentino,
Thanks for the response. Eventually ended up solving it by fixing which layer the environmental elements go in. Also, Alex, you were right about the hybrid mode. It just wasn’t showing everything in the right spots so I turned it off and what’s actually going on seems to be working fine. Thanks
Hope all is going well with both of you!
Hi @jhow,
Can you clarify “don’t anchor with the display objects they are tied to”? Do you mean the “hybrid” draw mode for physics bodies? Clearly, physics bodies remain associated/tied to the object they’re on… that rule can’t be broken. What you might be seeing is related to the draw mode.
Best regards,
Brent
Hi Brent,
Can you clarify “don’t anchor with the display objects they are tied to”?
The physics bodies are not in the position that they should be (as if they are not attached to their respective display objects). If I move my display object that is the focus of the scene, all the environmental objects compensate in the opposite direction. But the physics bodies of those environmental objects stay put and don’t move with their respective display objects.
In the correct scenario, for all the display objects that move on screen, their respective physics bodies (collision boxes in hybrid mode) would move with them (ie. they are anchored together).
Do you mean the “hybrid” draw mode for physics bodies?
Yes. I am doing my testing in “hybrid” mode so I can see where my physics bodies are with respect to their associated display object.
Clearly, physics bodies remain associated/tied to the object they’re on… that rule can’t be broken.
Yes, the physics bodies (ie. collision boxes in hybrid mode) are present and seen. But they are not moving with their respective display objects. In other words, when my objects on screen are in motion, their physics bodies (represented by transparent boxes in hybrid mode) are not moving with them.
Is this issue happening because maybe the Perspective Virtual Camera System is incompatible with Corona’s physics?
There shouldn’t be a problem with the compatibility, insomuch as the Perspective library doesn’t do anything different for physics objects than it would for simple objects. Your best bet is to confirm that the physics bodies are interacting abnormally, rather than just the hybrid filter showing that they aren’t visually performing as you might expect. I’ve run into some situations where the hybrid overlay is giving me false info; the bodies are doing their thing, but it appears as though their boundaries are all over the place. Seems like the hybrid filter is more of a guideline than a rule
To clarify, this goes back to what we recommend you never do with the physics engine, and what we advise in the docs and many forum posts over the years: never move display groups containing physics objects independently of other groups. That will break collisions. You need to move the entire physics “world” in lock step if you want to use a world-camera style system.
Personally, I haven’t used the Perspective library enough to know if it’s obeying this rule of thumb. If I recall, Perspective handles multiple layers of parallax scrolling at different rates, so if you put physics objects in different layers moving at different speeds, but you expect them to interact/collide with each other “between layers”, then you’ll face issues.
Also, note that we made a noticeable change to the hybrid draw system in a daily build since the last public release. Since forever, the hybrid views would not move in accordance with a shifted display group. This was a known bug. We fixed that and now hybrid view should actually be more accurate. However, I think I’d have to see your code to see what is not working as you expect it… if you can wrap up a small sample, I can take a look.
Best regards,
Brent
@Alex@Panc and @Brent Sorrentino,
Thanks for the response. Eventually ended up solving it by fixing which layer the environmental elements go in. Also, Alex, you were right about the hybrid mode. It just wasn’t showing everything in the right spots so I turned it off and what’s actually going on seems to be working fine. Thanks
Hope all is going well with both of you!