- Home /
Making the avatar look toward a specific direction
Hello everybody,
I have several avatars patrolling to random points in my scene. Once the user enters the collider the avatars approach him. My goal is to have the avatars face the same direction as the user. If user faces wall X, I want the avatar to face wall X. Right now they approach the user and some face the user, some face the other way... It has to be under control.
I'll note that this is a VR environment, I don't use any form of ray cast except for teleporting. How can I control this?
Answer by yaezah · May 15, 2017 at 09:08 PM
What about adding an empty gameobject in front of the VR camera (as the camera's child) and raycasting forward , then when your player faces wall x , you make the other avatars face the ray's direction or ray point?
Answer by IMemeManI · May 16, 2017 at 04:35 PM
this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), 0.1f);
@Eco-Editor I'f i'm not mistaken, that should make the AI look at the Player, I use this in my Zombie script to have the Zombie look at my Player, It's not what you asked for but it'll fix the looking away problem and maybe you can adjust it to work with your project.