Collision()
Syntax: _Collision(object1, object2)
Purpose: Checks for active collisions between two designated objects.
Parameters:
object1, object2: The names of the objects to check. Wildcards are supported for more general matching.
Returns:
true/false: Indicates if a collision occurred.
obj1: Reference to the first object involved.
obj2: Reference to the second object involved.
x, y: The coordinates of the collision point (note the limitation for sensors)
Collision_Case, Collision_Handler_Settings, Collision_Handler, Collision_Handler_End
Purpose: These commands work together to define a sophisticated collision handling system for your physics-based interactions.
Collision_Handler_Settings: This initializes the process of defining your collision rules.
Collision_Case:
Inside a Collision_Handler_Settings
block, you define individual cases. Each case specifies two object
patterns (using wildcards as needed) that, if they collide, will
trigger some action.
Collision_Handler_End:
Closes out your Collision_Handler_Settings
block.
Collision_Handler:
Acts as a reference point for the collision handling function
created by your Collision_Handler_Settings
.
Example (Putting it Together)
Lua
-- Requires Physics to be activated
_Collision_Handler_Settings
_Collision_Case
"img_roca*"
,
"img_ship"
-- Rocks hitting the ship
_Collision_Case
"img_bullet*"
,
"img_enemy*"
-- Bullets hitting enemies
_Collision_Handler_End
Things to Note
Physics Required: These commands rely on the Lu C Studio physics system being activated in your project.
Wildcards: Use them strategically to define collision scenarios that match multiple objects.
No
Variables in Case Definitions:
Within the Collision_Handler_Settings
block, use object names with wildcards directly, rather than
variables.
Collision_Check()
This is a Lu C Studio internal function. While powerful, you likely won't interact with it directly.