RotateAround without transform


Unfortunately my game cannot rely on transform functions, so I have to rewrite them. So for example for:

transform.Translate(Vector3.forward * speed);

I use:

transform.position += Vector3.forward * speed;

How would I be able to apply this to RotateAround? Specifically:

transform.RotateAround(Vector3.forward, speed / 10f);

I tried things like

transform.position = Quaternion.Euler(0, 0, 1f) * transform.position; //etc

but that didn’t work… =/

I don’t know why your game can’t use Transform functions, but it can be done with the following code:

function RotateAround(center: Vector3, axis: Vector3, angle: float){
  var pos: Vector3 = transform.position;
  var rot: Quaternion = Quaternion.AngleAxis(angle, axis); // get the desired rotation
  var dir: Vector3 = pos - center; // find current direction relative to center
  dir = rot * dir; // rotate the direction
  transform.position = center + dir; // define new position
  // rotate object to keep looking at the center:
  var myRot: Quaternion = transform.rotation;
  transform.rotation *= Quaternion.Inverse(myRot) * rot * myRot;

Hope you can at least use Quaternion functions!

NOTE: This function is based on the original Unity code for RotateAround (thanks to ILSpy for that!).

You can use this C # script to rotate around with “D” AND “A” or arrows.

using UnityEngine;
using System.Collections;

public float rotateSpeed = 2.0F;
private Vector3 moveDirection =;

void Update() {

CharacterController controller = GetComponent<CharacterController>();


transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0); // Rotation