Collision: Difference between revisions

From Fancade Wiki
(Created page with "Checks the collision properties of the input object. 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 ob...")
 
(Related page)
Tags: Mobile edit Mobile web edit Advanced mobile edit
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Checks the collision properties of the input object.
{{Block
|image=Collision.png
|type=s
|folder=control
|input1={{Port|e|Before}}
|input2={{Port|o|1st Object}}
|output1={{Port|e|Collided}}
|output2={{Port|o|2nd Object}}
|output3={{Port|n|Impulse}}
|output4={{Port|v|Normal}}
|output5={{Port|e|After}}
}}
Detects collisions of the input [[object]] and outputs information about the collision.


Input:
Input:
Line 9: Line 21:
* Impulse: The impact force of the collision (how hard did they collide). Specifically, impulse is a change of momentum of an object.
* 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.
* Normal: The direction of the impact from the 2nd object to the 1st object.
[[File:Collision1.png]]


== Notes ==
== Notes ==


* If you're colliding with multiple objects it'll report the most forceful collision.
* 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.
* If you're overriding physics to move objects (using [[Set Position]]) then no collisions will occur.


== Examples ==
== Examples ==
[[Lose]] if the [[sphere]] touches the ground.
[[File:Collision example1.jpg|frameless|center|Example]]
Play a [[Play Sound|sound]] only if the impulse is big enough.
[[File:Collision example2.jpg|frameless|center|Example]]


The script below causes you to win if the two physics boxes collide with each other.
== Related ==
 
[[File:c1.png]]
 
Because the ground counts as "None", the script below causes you to lose if the sphere touches the ground.
 
[[File:c2.png]]
 
Triggers a sound effect only if the impulse is big enough.


[[File:20210103_135824.jpg]]
* [[Collider]]




[[Category:Blocks]]
[[Category:Blocks]]

Latest revision as of 14:22, 23 August 2025

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

Detects collisions of the input object and outputs information about the collision.

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
Example

Play a sound only if the impulse is big enough.

Example
Example

Related