it’s on AIPath and RichAI but it doesn’t look like it’s on FollowerEntity
or maybe i’m not understanding something. thanks
It looks like it doesn’t, no. I’m not seeing much information on it either- it may be implemented in some other way, seeing as FollowerEntity
is the newest of the three, by a long shot.
That said, if you simply want “lower speed when not looking at destination” I’d recommend something like the following:
public float minSpeed;
public float maxSpeed;
private FollowerEntity follower;
Vector3 directionToTarget = transform.position - target.transform.position;
float outputSpeed = Mathf.Lerp(minSpeed, maxSpeed, Vector3.Dot(transform.TransformDirection(Vector3.forward), directionToTarget.normalized));
follower.maxSpeed = outputSpeed;
This is just written really quickly, not tested at all. I also don’t know your specific needs so it’s more of the base idea than an actual implementation. But the idea is to use dot product to see how much the agent is facing towards the target, then lerping the speed based on the from the minSpeed to the maxSpeed.
Some notes: That Mathf.Dot wouldn’t work well because I didn’t clamp it to 0. As I’ve written it, it’s looking at the target, rather than the target direction to be walking, again mainly because I don’t know the use case. Fair warning to not copy this directly!!
But does this idea work in your use case?