Created
April 22, 2016 14:15
-
-
Save HyroVitalyProtago/0da89941ff12a6405d2beeaff5dba337 to your computer and use it in GitHub Desktop.
Generic script to always look at a transform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| public class AlwaysLookAt : MonoBehaviour { | |
| [SerializeField] Transform _transformToLookAt; | |
| void Update() { | |
| Vector3 v = _transformToLookAt.position - transform.position; | |
| v.x = v.z = 0.0f; | |
| transform.LookAt(_transformToLookAt.position - v); | |
| transform.Rotate(0,180,0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment