hi
i have the following script which works so far to follow a gameobject. I just cant get one part of it to work with playmaker FSM. The script works fine before i started writing this script.
the problem is only with the time on line 97 and where it has...
0.1fownergameobject.transform.rotation = Quaternion.Lerp (targetRotation.Value, targetgameobject.transform.rotation, 0.1f * Time.deltaTime);
Whatever i specify in this e.g. from 0.1 to 0.9 i cant get a delay to work. it seems to be ignoring the value. Not sure why? this works out of playmaker so i guess its something to do with playmaker causing this.
Nick
// (c) Copyright HutongGames, LLC 2010-2016. All rights reserved.
// Action made by NCMedia
// Rotate Player Over Time
// __ECO__ __PLAYMAKER__ __ACTION__
using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Transform)]
[Tooltip("This will transform rotate an object over a set time")]
public class RotateOverTime : FsmStateAction {
[RequiredField]
[Tooltip("Game Object to move")]
public FsmOwnerDefault owner; //owner
[RequiredField]
[Tooltip("Game Object to target")]
public FsmOwnerDefault target; //owner
[Tooltip("speed")]
public FsmFloat speed;
public FsmVector3 offsetPosition;
public Space offsetPositionSpace;
public bool lookAt = false;
public FsmQuaternion targetRotation;
private Vector3 lookAtPos;
private Vector3 lookAtPosWithVertical;
private FsmVector3 upVector;
public PlayMakerActionsUtils.EveryFrameUpdateSelector updateType;
public override void Reset()
{
owner = null;
target = null;
speed = 0.1f;
offsetPosition = null;
lookAt = false;
offsetPositionSpace = Space.Self;
targetRotation = new FsmQuaternion { UseVariable = true };
upVector = new FsmVector3 { UseVariable = true};
updateType = PlayMakerActionsUtils.EveryFrameUpdateSelector.OnUpdate;
}
public override void OnEnter()
{
DoFollowObject();
}
public override void OnUpdate()
{
if (updateType == PlayMakerActionsUtils.EveryFrameUpdateSelector.OnUpdate)
{
DoFollowObject();
}
}
void DoFollowObject () {
var ownergameobject = Fsm.GetOwnerDefaultTarget(owner); //get object
var targetgameobject = Fsm.GetOwnerDefaultTarget(target); //get target
// compute position
if(offsetPositionSpace == Space.Self)
{
ownergameobject.transform.position = targetgameobject.transform.TransformPoint(offsetPosition.Value);
}
else
{
ownergameobject.transform.position = targetgameobject.transform.position + offsetPosition.Value;
}
// compute rotation
if(lookAt)
{
ownergameobject.transform.LookAt(lookAtPos, upVector.IsNone ? Vector3.up : upVector.Value);
}
else
{
//ownergameobject.transform.rotation = targetgameobject.rotation;
targetRotation.Value = targetgameobject.transform.rotation;
ownergameobject.transform.rotation = Quaternion.Lerp (targetRotation.Value, targetgameobject.transform.rotation, 0.1f * Time.deltaTime);
}
}
}
}