Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to rotate object in unity only on one axis

// If you want the obj to rotate on only one axis do this

// Create vector3
Vector3 target_position = new Vector3(transform.position.x,
                                                target.position.y,
                                                transform.position.z);
// give the target_position to transform.LookAt

transform.LookAt(target_position);
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 :: how to add rigidbody in unity 
Csharp :: convert int32 
Csharp :: trygetvalue dictionary c# example 
Csharp :: c# xml to json 
Csharp :: check if palindrome recursion in c# 
Csharp :: stringbuilder to string c# 
Csharp :: msbuild publish to folder command line .net 
Csharp :: c# int 
Csharp :: quotes in string f# 
Csharp :: first person mouse look unity 
Csharp :: simple code to call rest api c# 
Csharp :: unity add button 
Csharp :: wpf stackpanel 
Csharp :: dapper sql builder where 
Csharp :: c# example code 
Csharp :: authentication and authorization in asp.net c# with example 
Csharp :: get number of days between two dates c# 
Csharp :: if statement 
Csharp :: c# add key value pair to dictionary 
Csharp :: ActionExecutingContext result response return 
Csharp :: how to turn components on and off in unity through code 
Csharp :: unity check if current scene is being unloaded 
Csharp :: c# how to append in array 
Csharp :: unity soft body 
Csharp :: search of specified registry key 
Csharp :: center mouse unity 
Csharp :: c# generic return type in interface 
Csharp :: foreach c# linq example 
Csharp :: c# calendar button random dates 
Csharp :: int array to frequency dictionary c# 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =