unity rotate towards mouse
C#
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#:
- Title
- string.charat c#
- Category
- C#
- Title
- c# anonymous class
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- math class C# exponents
- Category
- C#
- Title
- add getenumerator to class c#
- Category
- C#
- Title
- c# polymorphism
- Category
- C#
- Title
- c# ramdom
- Category
- C#
- Title
- void start
- Category
- C#
- Title
- how to turn a string in a char list c#
- Category
- C#
- Title
- unity gizmo draw line
- Category
- C#
- Title
- asp.net c# set session timeout
- Category
- C#
- Title
- .net core executenonqueryasync transaction
- Category
- C#
- Title
- c# directories loop
- Category
- C#
- Title
- c# storing value in session
- Category
- C#
- Title
- snake game
- Category
- C#
- Title
- How to get the world position of the edge of an object?
- Category
- C#
- Title
- top down movement unity c#
- Category
- C#
- Title
- count number of enum values C#
- Category
- C#
- Title
- disable button in android studio
- Category
- C#
- Title
- waitforseconds unity
- Category
- C#
- Title
- unity add sections to a list
- Category
- C#
- Title
- unity 2d joystick controls
- Category
- C#
- Title
- c# how to print
- Category
- C#
- Title
- how to display an image url in c# picturebox
- Category
- C#
- Title
- const float c#
- Category
- C#
- Title
- start up file in asp.net core
- Category
- C#
- Title
- get list length c#
- Category
- C#
- Title
- c# enum variable set to nonthing
- Category
- C#
- Title
- c# two dimensional array
- Category
- C#
- Title
- c# group array based on first character
- Category
- C#
- Title
- xml node update attribute value c#
- Category
- C#
- Title
- c# empty array
- Category
- C#
- Title
- c# md5 int
- Category
- C#
- Title
- unity detect any key
- Category
- C#
- Title
- how to add movement in unity
- Category
- C#
- Title
- unity fall damage c#
- Category
- C#
- Title
- animator hash in unity
- Category
- C#
- Title
- console.writeline c#
- Category
- C#
- Title
- c# list to string comma separated
- Category
- C#
- Title
- unity html request
- Category
- C#
- Title
- get setter c# model
- Category
- C#
- Title
- reverse string c#
- Category
- C#
- Title
- vector3.lerp
- Category
- C#
- Title
- HashSet C# append
- Category
- C#
- Title
- json serialize object capitalization config
- Category
- C#
- Title
- unity array c#
- Category
- C#
- Title
- how to a equall to b in c#
- Category
- C#
- Title
- string.insert c#
- Category
- C#
- Title
- unity particle system color
- Category
- C#
- Title
- Instantiate c#
- Category
- C#
- Title
- newtonsoft create dynamic object
- Category
- C#
- Title
- c# implement a superclass in subclass
- Category
- C#
- Title
- cc# sort list with list if ids
- Category
- C#
- Title
- how to disable device guard or credential guard vmware
- Category
- C#
- Title
- how to close a form c#
- Category
- C#
- Title
- unity quaternion identity
- Category
- C#
- Title
- .net core session
- Category
- C#
- Title
- c# read all lines from filestream
- Category
- C#
- Title
- page parent wpf
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- how to track a branch on github
- Category
- C#
- Title
- c# textbox tab column
- Category
- C#
- Title
- c# display float with 2 decimal places
- Category
- C#
- Title
- for each textbox c#
- Category
- C#
- Title
- how to exit a program in c#
- Category
- C#
- Title
- c# variable declaration
- Category
- C#
- Title
- decimals not stored in azure tables
- Category
- C#
- Title
- C# for
- Category
- C#
- Title
- create char array c#
- Category
- C#
- Title
- c# get enum value from string
- Category
- C#
- Title
- progress openedge odbc connection string c#
- Category
- C#
- Title
- random class
- Category
- C#
- Title
- countdown script in unity
- Category
- C#
- Title
- unity how to make a ui disappear
- Category
- C#
- Title
- find mongodb c# with task T
- Category
- C#
- Title
- get attribute value of xml element c#
- Category
- C#
- Title
- convert double to currency c#
- Category
- C#
- Title
- c# get pc ip address
- Category
- C#
- Title
- change text color wpf
- Category
- C#
- Title
- change navigation bar of master detail page xamarin form
- Category
- C#
- Title
- c# keyvaluepair
- Category
- C#
- Title
- c# console delay
- Category
- C#
- Title
- how to switch scenes unity
- Category
- C#
- Title
- blazor wasm routable page in separate project
- Category
- C#
- Title
- c# image to byte array
- Category
- C#
- Title
- c# how to check if two lists have same values
- Category
- C#
- Title
- countdown script unity
- Category
- C#
- Title
- unity c# run a command then wait
- Category
- C#
- Title
- how to start grid from where the data starts in c# charts
- Category
- C#
- Title
- unity get decimal part of float
- Category
- C#
- Title
- reload scene unity
- Category
- C#
- Title
- c# property get set
- Category
- C#
- Title
- c list add element
- Category
- C#
- Title
- bundle.config in mvc is missing
- Category
- C#
- Title
- navigate to another page with an object uwp c#
- Category
- C#
- Title
- unity delete all children
- Category
- C#
- Title
- unity face direction of movement
- Category
- C#
- Title
- get what week of the month c#
- Category
- C#
- Title
- c# listview
- Category
- C#
- Title
- unity how to move an object to another object
- Category
- C#