Make world UI always always look at camera unity tutorial | Rotate gameObject towards camera unity
ASSALAM o alaikum In this video we have shown how to rotate world ui or any object always look at camera
Code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LookAtCamera : MonoBehaviour
{
public Camera camera;
public Transform objectToRotate;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
objectToRotate.rotation = Quaternion.Slerp(objectToRotate.rotation,camera.transform.rotation,3f*Time.deltaTime);
}
}
/*
/////////////////////////////////////////////////////////////////////////////////////////////
ASSALAM o alaikum
All codes and concepts and videos from this channel are non copyrighted and free to use because we believe that knowledge should be freely available for everyone
/////////////////////////////////////////////////////////////////////////////////////////////
*/