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 rotate around axis

transform.Rotate(axis, degrees);
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# substring find word 
Csharp :: c# get every point in a line in matrix 
Csharp :: unity reload active scene 
Csharp :: cache trong mvc 
Csharp :: C# order a sorted list by key 
Csharp :: c# create a dummy class 
Csharp :: unity unhide object 
Csharp :: number to character c# 
Csharp :: linear search algorithm c# 
Csharp :: request a pricipal permission 
Csharp :: web client ignore ssl error 
Csharp :: c# lambda group by multiple columns 
Csharp :: unity stop physics 
Csharp :: how to access resources in c# 
Csharp :: trhow exception if is null c# 
Csharp :: unity awake 
Csharp :: Response.Redirect cannot be called in a Page callback 
Csharp :: select a whole row out of a 2d array C# 
Csharp :: c# in equivalent 
Csharp :: unity3d gameobject follow path 
Csharp :: gql query with parameters 
Csharp :: c# string length 
Csharp :: c# Write a program to reverse an array or string 
Csharp :: how to set a color of text in unity 2020 script 
Csharp :: c# how to get a securestring from string 
Csharp :: longest palindromic substring 
Csharp :: convert stream to base64 string c# 
Csharp :: calculate string length vs pixels c# 
Csharp :: how to instantiate more enemies in unity 
Csharp :: aspnet for loop 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =