Collision detection inside box
by Daryll Todd · in Torque Game Engine · 09/10/2008 (6:47 am) · 9 replies
Hi,
Does anyone know how to setup collision detection inside a hollow box (the hollow box being a single png with a transparent centre)?
As far as I can tell the detection only works on the outside of the box, not the inside? Having read about convex collision boxes im wondering if thats the reason..
As an alternative I could break the box into 4 separate sides - although this works I cant seem to group them so they can have a behaviour applied to them as one?
Sorry if thats not very clear, is it possible to do either of the above?
Does anyone know how to setup collision detection inside a hollow box (the hollow box being a single png with a transparent centre)?
As far as I can tell the detection only works on the outside of the box, not the inside? Having read about convex collision boxes im wondering if thats the reason..
As an alternative I could break the box into 4 separate sides - although this works I cant seem to group them so they can have a behaviour applied to them as one?
Sorry if thats not very clear, is it possible to do either of the above?
#2
09/10/2008 (7:06 am)
Probably you need to break it into 5 objects. One static sprite in the center with your png box image, and four invisible objects mounted to it with the collision polygons for each side. Still they would be separate object's and a collision with one would generate a oncollision callback for only that object. But you could add behaviors to the central object to do some things, just not handle callbacks.
#3
Sorry about that, box was probably the wrong word, yes im talking about 2D collisions inside a rectangle or square ( or any hollow 2D shape)
Imagine a 2D circle inside a hollow 2D rectangle, if for example the circle were to be moved around id want it to bounce off the sides..at the minute the circle passes straight through, once outside the rectangle, if the circle tries to move back inside, the collision works fine and it bounces off.
Thanks for the quick response btw :)
09/10/2008 (7:11 am)
Hi,Sorry about that, box was probably the wrong word, yes im talking about 2D collisions inside a rectangle or square ( or any hollow 2D shape)
Imagine a 2D circle inside a hollow 2D rectangle, if for example the circle were to be moved around id want it to bounce off the sides..at the minute the circle passes straight through, once outside the rectangle, if the circle tries to move back inside, the collision works fine and it bounces off.
Thanks for the quick response btw :)
#4
09/10/2008 (7:18 am)
Perhaps you could use world limits on the ball to accomplish that. Its easier if the box is stationary, but even if it moves you can recalculate the worldlimits for the ball. Well unless the box rotates, then it wouldn't work.
#5
Ill do some more reading, I wonder if I can rotate the camera or something instead.
09/10/2008 (8:00 am)
Hmm ok thanks guys, I was planning on being able to rotate the box so maybe ill have to re think this a bit.Ill do some more reading, I wonder if I can rotate the camera or something instead.
#6
Ive been looking through the documentation and I cant seem to find any mention of how to rotate the camera?
My camera will track an object in x & y but can anyone give me any pointers for rotating?
09/10/2008 (9:23 am)
Not sure if I should start a new thread for this but here I go anyway..Ive been looking through the documentation and I cant seem to find any mention of how to rotate the camera?
My camera will track an object in x & y but can anyone give me any pointers for rotating?
#7
09/10/2008 (10:53 am)
You could add that feature to t2dScenWindow with C++ changes, but I don't think it is a feature of stock TGB.
#8
http://www.garagegames.com/products/62/
09/10/2008 (11:29 am)
Ok then thanks, ill look into that, its a shame - I thought it was standard as its mentioned in the features:http://www.garagegames.com/products/62/
#9
Actually looking back it sounds pretty similar to your original suggestion James.
09/12/2008 (10:37 am)
Just for reference - I was able to solve my original issue by mounting the individual sides to an empty scene object - the rectangle can then be controlled by applying the behaviour to the empty scene object.Actually looking back it sounds pretty similar to your original suggestion James.
Torque Owner Stefan Lundmark
Looks to me like you're talking about a rectangle, and not a box. You want 2D collisions on a png on your GUI, or what? Some details and I'm sure you'll get the help you want.