Expected behavior
Target Sensor is created with proper position but doesn't update as the GameObject it bases its position on moves.
Screenshots
Code
using CrashKonijn.Agent.Core;
using CrashKonijn.Goap.Runtime;
using UnityEngine;
namespace Assets.Scripts.GOAP
{
public class LoosePuckSensor : LocalTargetSensorBase
{
GameController _gameController;
Vector3 _puckPosition;
public override void Created()
{
_gameController = GameObject.Find("GameController").GetComponent<GameController>();
}
// Is called every frame that an _agent of an `AgentType` that uses this sensor needs it.
// This can be used to 'cache' data that is used in the `Sense` method.
// Eg look up all the trees in the scene, and then find the closest one in the Sense method.
public override void Update()
{
_puckPosition = _gameController.Puck.transform.position;
Debug.Log(_puckPosition);
}
public override ITarget Sense(IActionReceiver agent, IComponentReference references, ITarget existingTarget)
{
if (_gameController == null) return null;
if (_gameController.Puck == null) return null;
if (existingTarget is PositionTarget positionTarget)
{
return positionTarget.SetPosition(_puckPosition);
}
return new PositionTarget(_puckPosition);
}
}
}
Package Version
v3 beta
Additional context
Add any other context about the problem here.
Expected behavior Target Sensor is created with proper position but doesn't update as the GameObject it bases its position on moves.
Screenshots
Code
Package Version v3 beta
Additional context Add any other context about the problem here.