playMaker

Author Topic: Using transform.position in custom action script [SOLVED]  (Read 4796 times)

MattyWS

  • Junior Playmaker
  • **
  • Posts: 90
Using transform.position in custom action script [SOLVED]
« on: July 29, 2013, 03:34:32 PM »
Hello again! I'm trying to write a custom script for an action that I know should work (it's been working fine in normal c# attached to the object). I'm not entirely sure what I'm doing wrong but I'm sure it's just me not understanding playmaker well enough.

The script is as follows;

Code: [Select]
using UnityEngine;
using HutongGames.PlayMaker;

[ActionCategory("MinimapInfo")]
public class BlueBlip : FsmStateAction

{
public Texture Blip;
Vector3 TargetPosition;
// Code that runs on entering the state.
public override void OnEnter()
{
TargetPosition = transform.position;
}

// Code that runs every frame.
public override void OnUpdate()
{

}

void OnGUI ()
{

GUI.DrawTexture(new Rect(transform.position.x/100*150+81, Screen.height-89 -+transform.position.z/100*150, 8, 8), Blip);

}

}

and the error I get is as follows

Quote
Assets/PlayMaker/Actions/MinimapInfo/BlueBlip.cs(13,34): error CS0103: The name `transform' does not exist in the current context

Would anyone be able to shed some light on what I'm doing wrong here?

Thanks,
MattyWS
« Last Edit: July 30, 2013, 10:54:39 PM by Alex Chouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Using transform.position in custom action script
« Reply #1 on: July 29, 2013, 07:56:44 PM »
transform is a MonoBehaviour property, in an FsmStateAction you need to do:

Fsm.GameObject.transform

The action is in an Fsm, the Fsm is on a GameObject...

MattyWS

  • Junior Playmaker
  • **
  • Posts: 90
Re: Using transform.position in custom action script
« Reply #2 on: July 30, 2013, 03:11:49 PM »
Thanks! That helped, there was also another issue with onGUI (needed to be override ongui).

Problem solved though! I now have a minimap with blips where the tanks are without using a second camera. :)