Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: WitchTheWicked on December 31, 2011, 04:31:31 PM

Title: Get Distance without using Y [SOLVED]
Post by: WitchTheWicked 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;

Title: Re: Get Distance without using Y
Post by: jeanfabre 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 :)