Bounce a ball inside a square?
by Ty Newton · in Torque X 2D · 01/10/2007 (9:28 pm) · 5 replies
Hey,
I'm a noob so please try to be patient with me.
I've modified the StarterGame to make the GG logo bounce around an invisible square. I used the T2DWorldLimit and the T2DPhysics components for this.
I want to see the square that the GG logo is bouncing off. What's the best way to achieve this?
I tried drawing a square, adding it as a new material, setting its collision polygon. When the GG logo is inside the square and travels outside of it no collision occurs. When the GG logo is outside the square and tries to move inside of it a collision occurs. I want the GG logo to bounce around inside the square.
Any ideas?
I'm a noob so please try to be patient with me.
I've modified the StarterGame to make the GG logo bounce around an invisible square. I used the T2DWorldLimit and the T2DPhysics components for this.
I want to see the square that the GG logo is bouncing off. What's the best way to achieve this?
I tried drawing a square, adding it as a new material, setting its collision polygon. When the GG logo is inside the square and travels outside of it no collision occurs. When the GG logo is outside the square and tries to move inside of it a collision occurs. I want the GG logo to bounce around inside the square.
Any ideas?
#2
There are multiple techniques, including putting border objects (4 total) on the sides of your square to represent each side and give the ball something to bounce against that is convex, or using a variation of world limits, or even simply not using built in collision and use a mathematical distance check of the ball from the center of the square, but by default you won't get a collision against an object when inside the object traversing out.
01/11/2007 (12:21 pm)
Torque X doesn't do concave collision, and by definition being "inside" something is basically concave.There are multiple techniques, including putting border objects (4 total) on the sides of your square to represent each side and give the ball something to bounce against that is convex, or using a variation of world limits, or even simply not using built in collision and use a mathematical distance check of the ball from the center of the square, but by default you won't get a collision against an object when inside the object traversing out.
#3
I read in the doco about the concave collisions and thought that was the problem. I thought it best to double check in case I missed a option somewhere.
I've decided to go with the 4 objects solution; one for each side of the square.
Thanks.
01/11/2007 (3:39 pm)
Thanks Stephen,I read in the doco about the concave collisions and thought that was the problem. I thought it best to double check in case I missed a option somewhere.
I've decided to go with the 4 objects solution; one for each side of the square.
Thanks.
#4
02/02/2007 (9:02 pm)
Can't you just set the world limits of your object to the square, and not the screen? So that the box is only there for visual purposes?
#5
02/05/2007 (3:07 am)
Yes, you are right. I chose the other way because I decided I wanted more flexibility.
Torque 3D Owner Jonathon Stevens