phy_col_normal_x

Returns the x component of the collision normal for the associated collision point.

Syntax:

phy_col_normal_x;


Returns: Boolean


Description

This read-only variable returns the x component of the collision normal corresponding to the phy_collision_x array value. For each contact point there is an associated contact normal (which is usually the same normal for all points of contact in the collision). This contact normal is a unit vector that points from one instance in the collision to another, and can be used, for example, to calculate the correct "push" direction to resolve collisions.

NOTE: This variable is only available in the collision event of a physics enabled instance.


Example:

repeat(5 + irandom(5))
   {
   with (instance_create(x, y, obj_Debris)
      {
      physics_apply_local_impulse(0, 0, other.phy_col_normal_x[0], other.phy_col_normal_y[0]);
      }
   }

The above code uses the contact normal to set the direction of movement for an instance created in the collision event between two physics enabled instances.


Back: Physics Variables
next: phy_col_normal_y
© Copyright YoYo Games Ltd. 2018 All Rights Reserved