system
1
Hey, I am working on my own AI right now, and i simply dont know how to code it.
I want, that my "Hunter" hunts the player only if he sees him.
i worked out that he only hunts him when hes nearer then 10 unity meters.
But know i want to be able to hide from him, by going behind a object, so he doesent sees me anymore.
and when that works, would like the hunter to move to the last point he saw the player..
is that even possible!!
Edit: here is some code that doesn’t work. Why?
var hit : RaycastHit;
var inSight = false
var playerRelativPos =myTransform.position - target.position;
if(Physics.Raycast(transform.position , playerRelativPos, hit, 1))
if(hit.transform == GameObject.FindWithTag("Player"))
inSight = true;
Loius
2
It is!!
Use Physics.Raycast towards the player, and store the player's last position each time you see it.