Author Topic: Get Distance without using Y [SOLVED]  (Read 3294 times)


  • Playmaker Newbie
  • *
  • Posts: 8
    • View Profile
Get Distance without using Y [SOLVED]
« on: December 31, 2011, 04:31:31 PM »
I tried my best to make an action script for playmaker but, I didn't get very far, spent a few hours looking at the API reference, there's a lot of TODO for the classes, not blaming that, but I need help please

Function Description : Gets distance between two gameobjects ignoring an AXIS (y).

I would like if a staff member could help me please. Thank you!

Code: [Select]
using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMaker.Actions
[Tooltip("Gets distance without the Y axis involved.")]
public class GetDistNoY : FsmStateAction
public FsmGameObject objectSrc;

        public FsmOwnerDefault objectDest;

public FSMFloat storeResult;

public bool everyFrame;

public override void Reset()
definition = null;
theValue = null;
storeResult = null;
everyFrame = false;

public override void OnEnter()

if (!everyFrame)

public override void OnUpdate()

void DoFindDistanceNoY()
            Transform transformSrc = objectSrc.GetComponent<Transform>();
            Transform transformDest = objectDest.GetComponent<Transform>();

            storeResult.Value = transformSrc.position.x;

« Last Edit: January 14, 2012, 05:30:23 PM by alexchouls »


  • Administrator
  • Hero Member
  • *****
  • Posts: 15398
  • Official Playmaker Support
    • View Profile
Re: Get Distance without using Y
« Reply #1 on: January 02, 2012, 01:29:14 AM »

 ok, here we go:

Basically you were not far from an playmaker action implementation point of view, it's only the math and logic of the distance computation that was not really the right one.

I made that action more flexible by allowing you to ignore any or a combination of axis. so to ignore the y axis check the "ignore Y" and you will get the distance between two object on the world XZ plane.

 If you need more help, don't hesitate :)