You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingUnityEngine;usingSystem.Collections;publicclassLookTowardMouse:MonoBehaviour{voidUpdate(){//Mouse Position in the world. It's important to give it some distance from the camera. //If the screen point is calculated right from the exact position of the camera, then it will//just return the exact same position as the camera, which is no good.Vector3mouseWorldPosition=Camera.main.ScreenToWorldPoint(Input.mousePosition+Vector3.forward*10f);//Angle between mouse and this objectfloatangle=AngleBetweenPoints(transform.position,mouseWorldPosition);//Ta daatransform.rotation=Quaternion.Euler(newVector3(0f,0f,angle));}floatAngleBetweenPoints(Vector2a,Vector2b){returnMathf.Atan2(a.y-b.y,a.x-b.x)*Mathf.Rad2Deg;}}
The text was updated successfully, but these errors were encountered:
1.Look towards player
The text was updated successfully, but these errors were encountered: