playMaker

Author Topic: Making a playmaker action error CS1061 [SOLVED]  (Read 3338 times)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Making a playmaker action error CS1061 [SOLVED]
« on: February 02, 2016, 02:06:54 PM »
Hi

I am making my C# script into a playmaker script so i can add it to the Ecosystem once tested. But i've not used GameObject references to FSM owner before and I have followed guides and looked at other script to see if i can resolve but i'm stuck with the following errors.

Error 1
Assets/PlayMaker Custom Actions/Time/MovingPlatformTest.cs(63,70): error CS1061: Type `HutongGames.PlayMaker.FsmOwnerDefault' does not contain a definition for `position' and no extension method `position' of type `HutongGames.PlayMaker.FsmOwnerDefault' could be found (are you missing a using directive or an assembly reference?)

Error 2
Assets/PlayMaker Custom Actions/Time/MovingPlatformTest.cs(66,42): error CS0019: Operator `+' cannot be applied to operands of type `float' and `HutongGames.PlayMaker.FsmFloat'

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved.
// Action made by NickCoxMedia
// __ECO__ __PLAYMAKER__  __ACTION__

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{

[ActionCategory(ActionCategory.Transform)]
[Tooltip("This will transform a object from one position to another")]
public class MovingPlatform : FsmStateAction
{

public FsmOwnerDefault gameObject; //owner

[RequiredField]
[Tooltip("How fast the platform moves")]
public FsmFloat Speed; //speed

[Tooltip("Choose a destination spot")]
public FsmOwnerDefault DestinationSpot;

[Tooltip("Choose a starting spot")]
public FsmOwnerDefault OriginSpot;

[Tooltip("shows when the platform returns")]
public FsmBool Switch = false;

[Tooltip("How long to delay before moving")]
public FsmFloat delayBeforeMoving;

private float pauseTime;
private bool arrivedAtOurDestination = false;


public override void Reset()
{
DestinationSpot = null;
OriginSpot = null;
Switch = false;
delayBeforeMoving = null;
gameObject = null; //owner null

}

public override void OnFixedUpdate()
{
DoMovingPlatform();
}


void DoMovingPlatform()
{

var go = Fsm.GetOwnerDefaultTarget(gameObject);
if(go == null) return;


// For these 2 if statements, it's checking the position of the platform.
// If it's at the destination spot, it sets Switch to true.
if((go.transform.position == DestinationSpot.position) && !arrivedAtOurDestination)
{
Switch = true;
pauseTime = Time.time + delayBeforeMoving;
arrivedAtOurDestination = true;
}


}
    }
}
« Last Edit: February 04, 2016, 06:28:55 AM by coxy17 »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Making a playmaker action error CS1061
« Reply #1 on: February 02, 2016, 06:09:00 PM »
Error 1:

You have to get the GameObject that the FsmOwnerDefault variable points to:

Code: [Select]
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go != null)
{
// do stuff
}

Error 2:

You have to use the Value property. e.g., fsmVariable.Value = 100f;

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Making a playmaker action error CS1061
« Reply #2 on: February 03, 2016, 08:44:35 AM »
thanks, i've solved 'Error 2' now. But I must be confused still as I've still got the same error for 'Error 1' now I've moved the code.

Code: [Select]
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go != null)
{
// do stuff

if((go.transform.position == DestinationSpot.position) && !arrivedAtOurDestination)
{
Switch = true;
pauseTime = Time.time + delayBeforeMoving.Value;
arrivedAtOurDestination = true;
}
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Making a playmaker action error CS1061
« Reply #3 on: February 04, 2016, 01:50:44 AM »
Hi,

 you need to do the same with "destinationSpot", it's also a FsmOwnerDefault and must treated like your "gameobject" variable.

Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: Making a playmaker action error CS1061
« Reply #4 on: February 04, 2016, 05:06:24 AM »
Hi

That's makes sense now, thanks. All working ok with my full code now.

Nick
« Last Edit: February 04, 2016, 06:28:44 AM by coxy17 »