NeOmega
New member
There is a disconnect somewhere, and I can't figure it out.
I have a Task script that says
everything works fine, on objects placed in the scene, but not on real time spawned pre-fabs.
But for some reason, animator.SetBool("attack", true); never gets set on real-time spawned pre-fabs. ((transform.LookAt() and SetTopSpeed() work on both editor placed and cloned prefabs)
Again, it works perfectly on prefabs placed in scene, but fails when cloned by a simple spawner, although still returns success.
I just cant figure it out. I've tried swapping around OnAwake()'s vs OnStarts()'s as that is as far as I can figure where the disconnect is.
I have a Task script that says
Code:
using UnityEngine;
namespace BehaviorDesigner.Runtime.Tasks.Movement
{
[HelpURL("https://opsive.com/support/documentation/behavior-designer/writing-a-new-conditional-task/" + " YouTube https://youtu.be/q58ELfkyjQk?t=79")]
[TaskIcon("Assets/Behavior Designer Movement/Editor/Icons/{SkinColor}CanSeeObjectIcon.png")]
[TaskCategory("Attack")]
public class PoleArm_Attack : Action
{
public SharedTransform targetTransform;
public SharedFloat weaponRange;
public SharedFloat attackSpeed;
//fieldOfviewAngle for drawing attack range gizmo
float fieldOfViewAngle = 90.0f;
Animator animator;
SpeedEnergyWill speedEnergyWill;
public override void OnStart()
{
animator = GetComponent<Animator>();
speedEnergyWill = GetComponent<SpeedEnergyWill>();
}
public override TaskStatus OnUpdate()
{
if (targetTransform.Value != null)
{
transform.LookAt(targetTransform.Value);
speedEnergyWill.SetTopSpeed(0.0f);
animator.SetBool("attack", true);
}
return TaskStatus.Success;
}
public override void OnDrawGizmos()
{
MovementUtility.DrawLineOfSight(Owner.transform, /*offset.Value*/Vector3.zero, fieldOfViewAngle, /*angleOffset2D*/0.0f, weaponRange.Value, false, Color.red);
}
public override void OnBehaviorComplete()
{
MovementUtility.ClearCache();
}
}
}
everything works fine, on objects placed in the scene, but not on real time spawned pre-fabs.
But for some reason, animator.SetBool("attack", true); never gets set on real-time spawned pre-fabs. ((transform.LookAt() and SetTopSpeed() work on both editor placed and cloned prefabs)
Again, it works perfectly on prefabs placed in scene, but fails when cloned by a simple spawner, although still returns success.
I just cant figure it out. I've tried swapping around OnAwake()'s vs OnStarts()'s as that is as far as I can figure where the disconnect is.
Last edited: