I have a game object, a pig in fact, which is looking for mushrooms using Raycast. While searching, the pig changes its direction every 2 seconds.
When it raycasts a target, it goes to it :
this.transform.position = Vector3.MoveTowards(this.transform.position, mushPosition, speedPig * Time.deltaTime);
But as the pig is not a point, and as the Character Controller is a the center of the Pig, it may not be “facing” its target. I’ve been trying to resolve that dummy question all day long, but in vain. I get its rotation value at the moment it finds the mushroom using this.transform.rotation.y but what next ? Can’t figure the math…
So if anyone can help a newbie trying to help pigs eating mushrooms… it would be nice.
Thanks in advance