point_distance_3d

Returns the length of a vector comprised of the specified components.

Syntax:

point_distance_3d(x1, y1, z1, x2, y2, z2);


Argument Description
x1 The x coordinate of the first component of the vector
y1 The y coordinate of the first component of the vector
z1 The z coordinate of the first component of the vector
x2 The x coordinate of the second component of the vector
y2 The y coordinate of the second component of the vector
z2 The z coordinate of the second component of the vector


Returns: Real


Description

This function takes the supplied components of the vector and returns the length (distance) of the vector. It works in exactly the same way as point_distance() but with the addition of factoring in the z value (depth) for use in 3D space.


Example:

var inst, ex, ey, ez;
inst = instance_nearest(x, y, enemy);
if inst
   {
   ex = inst.x;
   ey = inst.y;
   ez = inst.z;
   if point_distance_3d(x, y, z, ex, ey, ez) < 200
      {
      instance_create(x, y, obj_Missile)
      }
   }

The above code will get the x and y and z coordinates of the nearest enemy and then use them to check the distance (length) of the vector formed by them and the player coordinates. If the value is less than 200, the player object will create an instance of "obj_Missile".


Back: Vector Functions
Next: dot_product
© Copyright YoYo Games Ltd. 2018 All Rights Reserved