TorqueX 2 - Collision not working when Rotation is modified
by Eduardo Baiao · in Torque X 2D · 09/11/2008 (9:19 am) · 8 replies
Hi,
When I use this code on the ProcessTick event:
to rotate an Shield around a Planet, the collision works, as we can see in the image:

But If I rotate the Shield this way:
the collision stops working.
Take a look:

I'm rendering the collision bounds and it is ok.
Is this a bug on the engine?
When I use this code on the ProcessTick event:
Shield.Physics.AngularVelocity += moveApplyed;
to rotate an Shield around a Planet, the collision works, as we can see in the image:
But If I rotate the Shield this way:
Shield.Rotation += moveApplyed;
the collision stops working.
Take a look:
I'm rendering the collision bounds and it is ok.
Is this a bug on the engine?
About the author
#2
09/12/2008 (5:02 am)
Thank's John!
#3
rotate it only with the physics and not the rotation attribute?
07/20/2009 (1:54 pm)
would this be the same for lighting a sprite with a normal map?rotate it only with the physics and not the rotation attribute?
#4
I'm guessing this is also the same reason why mounted objects don't collide?
07/20/2009 (7:42 pm)
Quote:No, this is exactly what is to be expected. In the first case, you are telling the Physics engine to do something, such as turn the shield. So, the Physics engine knows that the shield turned. In the second case, YOU turned the shield and the physics engine doesn't know anything about it. It's the same case in 3D games, which is why it is important tha players walking on the terrain use the Physics to push the player forward, rather than manually increment the player position manually. Just remember that what you see rendered on screen is completely decoupled from how the physics engine sees the world.
I'm guessing this is also the same reason why mounted objects don't collide?
#5
It's not quite the same. I know from looking inside the method that does the collision that one thing it does early on is to check whether the object is mounted. If so, a short block of code is executed and then returns, so the rest of the method is not run -> no collision. But this is inside the collision method, so presumably there would be no collision for a mounted object even if moved with physics.
As to why it doesn't do the collision for a mounted object, I have no idea.
07/20/2009 (9:19 pm)
@Lucas:It's not quite the same. I know from looking inside the method that does the collision that one thing it does early on is to check whether the object is mounted. If so, a short block of code is executed and then returns, so the rest of the method is not run -> no collision. But this is inside the collision method, so presumably there would be no collision for a mounted object even if moved with physics.
As to why it doesn't do the collision for a mounted object, I have no idea.
#6
Thanks for the technical clarification Scott. I had found a useful post some time back about mounted collisions here where GG explains a bit why mounted collisions don't work (and a bit on how to possibly to get it to work). I was originally going modify the source to get mounted collisions to work, but I found out that I didn't really need them in the end.
07/21/2009 (6:49 pm)
Quote:@Lucas:
It's not quite the same. I know from looking inside the method that does the collision that one thing it does early on is to check whether the object is mounted. If so, a short block of code is executed and then returns, so the rest of the method is not run -> no collision. But this is inside the collision method, so presumably there would be no collision for a mounted object even if moved with physics.
As to why it doesn't do the collision for a mounted object, I have no idea.
Thanks for the technical clarification Scott. I had found a useful post some time back about mounted collisions here where GG explains a bit why mounted collisions don't work (and a bit on how to possibly to get it to work). I was originally going modify the source to get mounted collisions to work, but I found out that I didn't really need them in the end.
#7
A rather central component to my game is you have to shoot the turrets off of a mothership to destroy it. I didn't think this was that out there. In fact, it's pretty much a staple of games like 1942 and Contra.
Are you seriously telling me this no longer works?
07/24/2009 (6:12 pm)
You've got to be kidding me... mounted collisions worked fine in TX2.0!A rather central component to my game is you have to shoot the turrets off of a mothership to destroy it. I didn't think this was that out there. In fact, it's pretty much a staple of games like 1942 and Contra.
Are you seriously telling me this no longer works?
#8
Unfortunately that's how its written. You can see it in the ProcessTick() method of T2DPhysicsComponent if you have the source code. This appears to be the case even with 2.0.
One time I tried rewriting it so that it did not return right away for mounted objects and instead continued through the rest of the method, but there were other problems, then (I don't recall what anymore). In the end I decided it wasn't really working and reverted it back to the original.
To simulate mounting for objects that I wanted to collide, I manually updated their position/rotation when the object it was "mounted" on changed. A little bit of work, but it eventually worked out.
07/24/2009 (7:31 pm)
@Talcott:Unfortunately that's how its written. You can see it in the ProcessTick() method of T2DPhysicsComponent if you have the source code. This appears to be the case even with 2.0.
One time I tried rewriting it so that it did not return right away for mounted objects and instead continued through the rest of the method, but there were other problems, then (I don't recall what anymore). In the end I decided it wasn't really working and reverted it back to the original.
To simulate mounting for objects that I wanted to collide, I manually updated their position/rotation when the object it was "mounted" on changed. A little bit of work, but it eventually worked out.
Associate John Kanalakis
EnvyGames
John K.