unity rotation
C#
using UnityEngine;// Transform.Rotate example
//
// This script creates two different cubes: one red which is rotated using Space.Self; one green which is rotated using Space.World.
// Add it onto any GameObject in a scene and hit play to see it run. The rotation is controlled using xAngle, yAngle and zAngle, modifiable on the inspector.public class ExampleScript : MonoBehaviour
{
public float xAngle, yAngle, zAngle; private GameObject cube1, cube2; void Awake()
{
cube1 = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube1.transform.position = new Vector3(0.75f, 0.0f, 0.0f);
cube1.transform.Rotate(90.0f, 0.0f, 0.0f, Space.Self);
cube1.GetComponent<Renderer>().material.color = Color.red;
cube1.name = "Self"; cube2 = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube2.transform.position = new Vector3(-0.75f, 0.0f, 0.0f);
cube2.transform.Rotate(90.0f, 0.0f, 0.0f, Space.World);
cube2.GetComponent<Renderer>().material.color = Color.green;
cube2.name = "World";
} void Update()
{
cube1.transform.Rotate(xAngle, yAngle, zAngle, Space.Self);
cube2.transform.Rotate(xAngle, yAngle, zAngle, Space.World);
}
}
var rotationVector = transform.rotation.eulerAngles;
rotationVector.z = 0; //this number is the degree of rotation around Z Axis
transform.rotation = Quaternion.Euler(rotationVector);
//if you put this in a coroutine and yielding for some amount of time
//you can have something like a rotating loading icon
Also in C#:
- Title
- when do i need to end a sentence with ; in c#
- Category
- C#
- Title
- unity gameobject.find
- Category
- C#
- Title
- find negative version of integer in c#
- Category
- C#
- Title
- snake
- Category
- C#
- Title
- c# webrequest cookies
- Category
- C#
- Title
- copy to clipboard unbity
- Category
- C#
- Title
- c# mixed multidimensional array
- Category
- C#
- Title
- unity how to change text in script
- Category
- C#
- Title
- how to record number of times using application in c#
- Category
- C#
- Title
- try catch c#
- Category
- C#
- Title
- bold caption latex
- Category
- C#
- Title
- displayname c#
- Category
- C#
- Title
- how to get the last element in an array in c#
- Category
- C#
- Title
- how to stop player rotating when hit by object
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- c# input integer
- Category
- C#
- Title
- move towards target unity
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- mouseposition unity
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- c# foreach arra
- Category
- C#
- Title
- wpf textblock line break code behind
- Category
- C#
- Title
- get enum value c#
- Category
- C#
- Title
- first person camera controller unity
- Category
- C#
- Title
- C# previous method
- Category
- C#
- Title
- asign only common fields in c# object
- Category
- C#
- Title
- unity randomly generated numbers c#
- Category
- C#
- Title
- c# if statement
- Category
- C#
- Title
- how to exit a program in c#
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- open file in explorer c#
- Category
- C#
- Title
- how to add array to list in c#
- Category
- C#
- Title
- unity resources load
- Category
- C#
- Title
- get all child gameObject of gameObject C#
- Category
- C#
- Title
- .sh script: check if file exist
- Category
- C#
- Title
- write last line txt file c#
- Category
- C#
- Title
- C# .net core convert string to enum
- Category
- C#
- Title
- array copy c#
- Category
- C#
- Title
- divide string in chunks c#
- Category
- C#
- Title
- socket in c#
- Category
- C#
- Title
- how to store some variables on the device in unity
- Category
- C#
- Title
- unity rotate object relative to camera
- Category
- C#
- Title
- razor preview
- Category
- C#
- Title
- unity c# get bool from another script
- Category
- C#
- Title
- c# image to byte array
- Category
- C#
- Title
- how to add a gameobject
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- c# find process by name
- Category
- C#
- Title
- c# getter setter
- Category
- C#
- Title
- unity how to get transform scale
- Category
- C#
- Title
- how to declare 2d array in c#
- Category
- C#
- Title
- uinput dialog uwp c#
- Category
- C#
- Title
- parse strings into words C#
- Category
- C#
- Title
- c# check internet connection easy
- Category
- C#
- Title
- c# regex replace
- Category
- C#
- Title
- webclient c# example post
- Category
- C#
- Title
- c# push numbers to array
- Category
- C#
- Title
- c# get country code
- Category
- C#
- Title
- math class C# exponents
- Category
- C#
- Title
- how to remove space between string in c#
- Category
- C#
- Title
- c# round to closest multiple
- Category
- C#
- Title
- c# remove last character from string
- Category
- C#
- Title
- convert number of days into months c#
- Category
- C#
- Title
- C# linq mselect
- Category
- C#
- Title
- unity coroutine
- Category
- C#
- Title
- asp.net core redirecttoaction with parameters
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- C# webclient immitate browser
- Category
- C#
- Title
- get setter c# model
- Category
- C#
- Title
- c# substring from index to end
- Category
- C#
- Title
- c# generic abstract method
- Category
- C#
- Title
- unity if gameobject exists
- Category
- C#
- Title
- C# loop through array of objet
- Category
- C#
- Title
- unity add component
- Category
- C#
- Title
- unity custom editor save changes
- Category
- C#
- Title
- cannot convert string to generic type c#
- Category
- C#
- Title
- get string character by index c#
- Category
- C#
- Title
- delay in unity
- Category
- C#
- Title
- unity how to make jump script
- Category
- C#
- Title
- debug.log unity
- Category
- C#
- Title
- basic sorting algorithms c#
- Category
- C#
- Title
- c# summary tag
- Category
- C#
- Title
- The type or namespace name 'Scrollbar' could not be found
- Category
- C#
- Title
- c# windows application get current path
- Category
- C#
- Title
- rotatearound unity
- Category
- C#
- Title
- c sharp create dictionary
- Category
- C#
- Title
- unity 2d joystick controls
- Category
- C#
- Title
- Add component object to gameobject unity
- Category
- C#
- Title
- flip boolean c#
- Category
- C#
- Title
- Execute code every x seconds with Update()
- Category
- C#
- Title
- button commandfield commandargument pass textbox
- Category
- C#
- Title
- unity fps counter
- Category
- C#
- Title
- unity delete all children
- Category
- C#
- Title
- how to add a list to observablecollection in c#
- Category
- C#
- Title
- c# map
- Category
- C#
- Title
- or in unity c#
- Category
- C#
- Title
- using serial port in c#
- Category
- C#
- Title
- void Update
- Category
- C#
- Title
- check for collision unity c#
- Category
- C#