Question by
Vladislav-Videnov · Apr 15, 2019 at 01:52 PM ·
camera-movementcamera-lookcamera followlookattarget
Make an object follow and face an object while maintaining distance from a different object.
Hello guys !
Currently i have an object that has 3D World Space canvas as a child ! The canvas is currently positioned above the object and is made to face the players camera ( VR camera ) with this code :
void Update()
{
Camera camera = Camera.main;
var lookPos = transform.position - camera.transform.position;
lookPos.y = 0;
var rotation = Quaternion.LookRotation(lookPos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2);
}
With some objects the positioning of the canvas does not work (its being blocked by the object) and i want it to follow the camera, while keeping a certain distance from the object its attached to..
Something like this :
Anybody has any suggestions how i can do it ?
mspaint-qohvnzett3.png
(28.3 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612195519im_/https://answers.unity.com/themes/thub/images/avi.jpg)