Skip to content

Instantly share code, notes, and snippets.

@tarob19 tarob19/RotateTest.cs
Last active Aug 29, 2015

What would you like to do?
Rotate sample component
using UnityEngine;
using System.Collections;
public class RotateTest : MonoBehaviour
public GameObject target;
public Vector3 additional;
Quaternion _rot;
Quaternion _initRot;
Vector3 _vec;
// Use this for initialization
void Start ()
_initRot = transform.rotation;
_rot = Quaternion.identity;
_vec = transform.position - target.transform.position;
// Update is called once per frame
void Update ()
_rot *= Quaternion.AngleAxis (180f * Time.deltaTime, Vector3.up);
var r = _rot * Quaternion.Euler (additional);
transform.position = r * _vec + target.transform.position;
transform.rotation = r * _initRot;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.