Collision

Revision as of 11:53, 17 May 2024 by Osmo (talk | contribs) (Updated and revisited the page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Checks the collision properties of the input object.

Collision
Collision.png
TypeScript block
ColliderNone
FolderControl
Ports
Inputs Before
1st Object
Outputs Collided
2nd Object
Impulse
Normal
After

Input:

  • 1st Object: The object that will send the collision data to this script.

Output:

  • Collided: Triggers when the input object collides with another object, including the floor.
  • 2nd Object: The object that the input object collided with. It outputs "None" if collided with the floor.
  • Impulse: The impact force of the collision (how hard did they collide). Specifically, impulse is a change of momentum of an object.
  • Normal: The direction of the impact from the 2nd object to the 1st object.

Notes

  • When colliding with multiple objects, only the most forceful collision will be reported.
  • Because only one collision at a time can be detected, resulting in inconsistent behaviour, it is recommended to avoid using it for critical elements of the game in favor of other methods.
  • If you're overriding physics to move objects (using Set Position) then no collisions will occur.

Examples

Lose if the sphere touches the ground.

 
Example

Play a sound only if the impulse is big enough.

 
Example