TX/Tutorials and Guides/TX UserGuide/World Limits

From TDN

This page is a Work In Progress.


Return To Contents Page

World Limits

Each object in a scene may also have a world limit, I.e. a bounded area of the scene which it must exist inside of. This is done by attaching a T2DWorldLimitComponent to the object (done automatically by TXB if you click on the "change the world limits for this object" button).

The T2DWorldLimitComponent gives you a MoveLimitMin (both X and Y) and MoveLimitMax (X and Y). These values define a rectangle in the scene. When any part of the object hits the limit, the WorldLimitResolveCollision response is invoked. The same options are available here as are available in the standard collision responses.

For example, if GarageGames.Torque.T2D.T2DPhyciscComponent.ClampCollision is selected, the object's velocity will be changed to prevent it from going out-of-bounds. There is also an OnWorldLimit callback available which can let you set up a method that is called when an object collides with its world limits.

World limits can be very useful in keeping the number of objects in your scene under control (which can be important for performance) -- for example, if you set up projectiles with the Kill response on their world limit they will effectively clean up after themselves when they miss because they'll delete themselves from the scene when they hit their world limit rather than hogging CPU cycles by flying off to infinity.


Return To Contents Page

This is Community Maintained, you may, and probably will, find out of date material. Feel free to update any of these articles yourself.