Transform.RotateAround / Obsolete / solution?


This is a simple script for rotating gameobject with mousedown. Everything fine, but I’m getting a warning : UnityEngine.Transform.RotateAround(UnityEngine.Vector3, float)' is obsolete: use Transform.Rotate instead.’ No big deal I guess, but when I try to change .RotateAround to .Rotate or any other solutions I’ve come up with, ingame rotation isn’t perfect. Any ideas? Thx.

using UnityEngine;
using System.Collections;
public class RotateUseMouse : MonoBehaviour {
public float sensitivityX = 10.0f;
public float sensitivityY = 10.0f;
public Transform cameraItem;
public bool down = false;
void Start () {
void Update () {
	if( Input.GetMouseButtonDown( 0 ) )
	down = true;
	else if( Input.GetMouseButtonUp( 0 ) )
	down = false;
	if( down ) {
	float rotationX = Input.GetAxis("Mouse X") * sensitivityX;
	float rotationY = Input.GetAxis("Mouse Y") * sensitivityY;
	transform.RotateAround( cameraItem.up, -Mathf.Deg2Rad * rotationX );
	transform.RotateAround( cameraItem.right, Mathf.Deg2Rad * rotationY );


Use the second overload of transform.rotate:

void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo);

Its the same as transform.RotateAround. The “relativeTo” is the point you want to rotate around.