Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

look rotation only on y axis in unity

        var dir = PlayerMovement.playerTransform.position - transform.position;
        Quaternion LookAtRotation = Quaternion.LookRotation(dir);

        Quaternion LookAtRotationOnly_Y = Quaternion.Euler(transform.rotation.eulerAngles.x, LookAtRotation.eulerAngles.y, transform.rotation.eulerAngles.z);
        transform.rotation = LookAtRotationOnly_Y;
Comment

Unity Object rotation along any axis

using UnityEngine;
public class Rotation : MonoBehaviour
{
    public float xAngle, yAngle, zAngle;

    public GameObject objectToRotate;

    void Awake()
    {
   //change position here to see object as want
        objectToRotate.transform.position = new Vector3(0.1f, 0.0f, 0.0f);
        objectToRotate.transform.Rotate(90.0f, 0.0f, 0.0f, Space.Self);

    }

    void Update()
    {
        objectToRotate.transform.Rotate(xAngle, yAngle, zAngle, Space.Self);
     
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# current dir 
Csharp :: c# list subfolders 
Csharp :: C# Program For Check Total Occurrence Of A Number In An Array 
Csharp :: unity detect keyboard not mouse 
Csharp :: system.drawing.color from hex 
Csharp :: .net framework get configuration value from web.config 
Csharp :: random.range unity not working 
Csharp :: unity how to get a child from a gameobject 
Csharp :: simple player controller unity 
Csharp :: how to close an application in c# 
Csharp :: get last 4 character c# 
Csharp :: yanderedev 
Csharp :: function in c# to do addition 
Csharp :: C# get md5 of file 
Csharp :: c# create list with range 
Csharp :: c# new dictionary linq 
Csharp :: c# messagebox result 
Csharp :: change dot net core web api routing 
Csharp :: Minimize window to system tray c# 
Csharp :: hide button unity 
Csharp :: check if internet is connected with c# winforms 
Csharp :: c# get country code 
Csharp :: how to stop animation unity 
Csharp :: array sort c# 
Csharp :: what is botnet attack 
Csharp :: c# see if list contains any duplicates 
Csharp :: rigidbody velocity c# unity 
Csharp :: show snackbar without scaffold flutter 
Csharp :: toggle unity c# 
Csharp :: get processor id c# web application 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =