Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Quaternion.Inverse

static function Inverse(rotation: Quaternion): Quaternion;
static Quaternion Inverse(Quaternion rotation);
static def Inverse(rotation as Quaternion) as Quaternion

Description

Returns the Inverse of rotation.

	// Sets this transform to have the opposite rotation of the target

var target : Transform; function Update () { transform.rotation = Quaternion.Inverse(target.rotation); }

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Transform target;
    void Update() {
        transform.rotation = Quaternion.Inverse(target.rotation);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public target as Transform

	def Update() as void:
		transform.rotation = Quaternion.Inverse(target.rotation)