Horje
Unity topdown 2d look Code Example
Unity topdown 2d look
// Note: You should cache Camera.main in Awake()
[SerializeField, Range(0, 50)] private float rotationSpeed = 25.0F;

private void Update()
{
  Vector2 directionDifference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
  float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
  Quaternion targetRotation = Quaternion.AngleAxis(angle, Vector3.forward);
  tranform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime); 

}




Csharp

Related
asp.net mvc get current url in view Code Example asp.net mvc get current url in view Code Example
defaultrequestheaders.authorization basic auth Code Example defaultrequestheaders.authorization basic auth Code Example
c# dictionary with multiple values Code Example c# dictionary with multiple values Code Example
how return only value of array in laravel Code Example how return only value of array in laravel Code Example
c# get country code Code Example c# get country code Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9