unity rotate towards mouse
using UnityEngine; using System.Collections; public class SCR_mouseRotation : MonoBehaviour { void Update () { Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.z, 10); Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos); lookPos = lookPos - transform.position; float angle = Mathf.Atan2(lookPos.z, lookPos.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.AngleAxis(angle, Vector3.down); // Turns Right transform.rotation = Quaternion.AngleAxis(angle, Vector3.up); //Turns Left } }
Also in C#:
- c# inheritance constructor
- c# get hwid
- unity rigid body variable
- datatable return column names
- Instantiate c#
- instantiate object in circle
- c# remove spaces from string
- download file from url asp net web api c#
- how to start an if statement in c#
- camera follow
- c# object to json string
- asp.net core allow all origins
- how to mock abstract httpcontext using moq .net core
- what data type should be for contact number in asp.net
- c# clone stream
- set decimal point c#
- top down movement unity
- unity rotate towards mouse
- serilog loglevel order
- asp.net core 3.1: cast jObject to dictionary<string,string>
- C# .net core convert string to enum
- c# ref
- repeat 10 timesw c#