Collisions (Solved)
by Anthony Mills · in Torque 2D Beginner · 06/23/2014 (7:58 am) · 7 replies
Hello,
I am trying to get collisions to happen between two objects and get the object to stop on the ground. When I move the character across it doesn't stop. I used Echo and put a break point there and i cant get it to trigger. you can find the project at https://github.com/zarashan/Game-Project
Thanks in Advance
Zarashan
I am trying to get collisions to happen between two objects and get the object to stop on the ground. When I move the character across it doesn't stop. I used Echo and put a break point there and i cant get it to trigger. you can find the project at https://github.com/zarashan/Game-Project
Thanks in Advance
Zarashan
#2
06/26/2014 (12:17 am)
I would like to thank you for your help. I got the collision to happen the main character can't go through, but when I turn on gravity. The ground is affected by gravity its a static body type, but i dont know why its still doing that.
#3
06/26/2014 (1:28 pm)
%object = new Sprite(); %object.setBodyType( static );This %object will not be affected by gravity.
#4
06/27/2014 (6:32 am)
OK I thinkg there is something messed up I have tried everything I set it up with the static bodyType modifier and its still not working you can view my code at the like above I still trying is there a getBody() type so I can check the ground
#5
06/27/2014 (6:58 am)
The problem is not with your ground object. You properly set it as a static body type and it is not affected by gravity. The issue is that you forgot to set your background image CompositeSprite to be a static body as well. And your gravity is working in the positive Y direction - so it gives the impression that the ground is falling down, when in reality it is the player and background falling up. All a matter of perspective. :)
#6
06/27/2014 (8:40 am)
Omg... I can't thank you enough I was wondering why in the tutorials the gravity was negative well I thank all of you you are all awesome.
#7
06/27/2014 (8:48 am)
Yeah, you have to be careful - in the old commercial T2D engine, the Y axis was inverted. So positive Y was screen down. But with the introduction of Box2D physics in T2D MIT the Y axis changed to the standard system where positive Y is screen up. Something to keep in mind if you stumble upon old tutorials or scripts on the internet. Anything on the Github wiki will be correct though.
Associate Mike Lilligreen
Retired T2Der
For the player sprite, you have the CollisionCallback field set to false. This means there would be no onCollision callback fired off - so you would not see the echo you put in there. As a first step, change that field to true.
For the wall object in the buildGround function, you have it set up as a sensor. Sensors register collisions but provide no physics response. Your player would not be stopped from moving then. The collision group is also set to 15, but your player sprite is in group 14. Change the collision group to 14 or the scene group on the player to 15 to make a collision happen.