World Limit
by LateNightCoder · in Torque X 2D · 09/14/2007 (2:04 pm) · 3 replies
Hi,
Anyone know if there is a way to detect which 'world limit' an object has collided with and then reacting differently depending on which limit was reached etc.
I remember using something along these lines in Torque script when I used TGB but can't seem to find anything similar in Torque X.
Any help appreciated.
Thanks.
Anyone know if there is a way to detect which 'world limit' an object has collided with and then reacting differently depending on which limit was reached etc.
I remember using something along these lines in Torque script when I used TGB but can't seem to find anything similar in Torque X.
Any help appreciated.
Thanks.
About the author
#2
If you add this to your MovementComponent's ProcessTick() method, you should be able determine which wall you hit based on the position of the owner scene object relative to the defined world limits.
A good use of this kind of function is a scrolling map camera, where the cursor roams around the scene and then only pans to other areas of the scene when the cursor hits the edge of the viewable area. This might not be what you're looking for, but hopefully it might point you in the right direction.
John K.
10/01/2007 (2:13 pm)
I don't think there is anything that directly tells you wich wall of the world limit was hit. But, you can probably do this in your code. For example, something like this in your ProcessTick() method:T2DWorldLimitComponent EndOfWorld =
_sceneObject.Components.FindComponent<T2DWorldLimitComponent>();
if (_sceneObject.Position.X >= EndOfWorld.MoveLimitMax.X)
doSomething(); //hit the right wall
if (_sceneObject.Position.X <= EndOfWorld.MoveLimitMin.X)
doSomething(); //hit the left wall
if (_sceneObject.Position.Y >= EndOfWorld.MoveLimitMax.Y)
doSomething(); //hit the bottom wall
if (_sceneObject.Position.Y <= EndOfWorld.MoveLimitMin.Y)
doSomething(); //hit the top wallIf you add this to your MovementComponent's ProcessTick() method, you should be able determine which wall you hit based on the position of the owner scene object relative to the defined world limits.
A good use of this kind of function is a scrolling map camera, where the cursor roams around the scene and then only pans to other areas of the scene when the cursor hits the edge of the viewable area. This might not be what you're looking for, but hopefully it might point you in the right direction.
John K.
#3
10/03/2007 (3:44 pm)
Excellent, thanks very much.
Torque Owner ChrisGWilliams