Unity Gizmo - how to

can somebody point me in the direction how to make
a gizmo somewhat similiar to the unity gizmo in the top right corner of unity editor.

so when i click on the axis camera rotates around the object…is is necessary to use quarternions?

anybody?

i imagine it would just involve zooming your camera far out and setting the rotation of it right

well, i guess that distance could be the same, i just need rotation of the camera around the object from one point to another. the end point should always be the same.

here is the picture, but it should be straitforward:

so i want the camera, which position is at Vector3(1,1,2) to rotate around the origin (or the point i choose) to Vector(0,-5,0)…

i was going through the reference and i found

 transform.RotateAround (Vector3.zero, Vector3.up, 20 * Time.deltaTime);

which might be helpful, so that means that i should calculate the angle, in my case, for z and x axis that i am going to use for rotation. so if i use this

 transform.RotateAround(Vector3.zero,Vector3(1,0,1),calculatedangle,Time*deltaTime);

i will get what i need? or i need to rotate separatly around axis? it is all very confusing i might add at start since i am a beginner.

also how to calculate the angle?
i guess this is a afternoon snack for the one that knows…

thanks!

im still a little unclear as to what you want - are you asking for the axis tool in the top right of the scene window in the editor???

either way i dont think you want to rotate around the x and z at the same time

yes i want something similiar to the tool in the editor window…basically i just want the functionallity, when i click a button, camera rotates around the object and sets in another position…

if doesnt need to be simulatanious, it just need to look that way… :slight_smile:

any ideas or pseudo code?

i altered a script i think i found on the wiki that handles moving a camera between different positions in the game world - if you up the camera move time i imagine you can make the transition quite fast

//set up blank game objects to represent the positions you want the main camera to move


var positions : GameObject[] = new GameObject[3];
var currPosition = 0;
var cameraMoveTime = 5;
var cameraMoving = false;




function OnGUI(){
	posX = Screen.width - 60;
	posY = Screen.height - 60;
	
	if(GUI.Button(Rect(posX,posY,50,50), "P1")){	
		if(currPosition != 0  cameraMoving == false)  {
			positionSwap(0);
			cameraMoving = true;
		}
	}
	
	//handles swapping to the 2nd camera
	if(GUI.Button(Rect(posX, posY-60,50,50), "P2")){	
		if(currPosition != 1  cameraMoving == false){
			positionSwap(1);
			cameraMoving = true;
		}
	}
	
	//handles swapping to the 3rd camera
	if(GUI.Button(Rect(posX, posY-120,50,50), "P3")){	
		if(currPosition != 2  cameraMoving == false)  {
			positionSwap(2);
			cameraMoving = true;
		}
	}	
	
}
function Update () {
	
	
	
}



function positionSwap (posNum){ 
   // Set up initial position 
  var initialPos = transform.position;
  var initialRot = transform.rotation;      
      // Lerp from current position to new position over time 
      var timeFactor = 1.0 / cameraMoveTime; 
      for (i = 0.0; i < 1.0; i += Time.deltaTime * timeFactor) { 
         // Make an index for ease in/ease out instead of the plain linear motion of "i" 
         var t = Mathf.SmoothStep(0.0, 1.0, i); 
         transform.position = Vector3.Lerp(initialPos, positions[posNum].transform.position, t); 
         transform.rotation = Quaternion.Slerp(initialRot, positions[posNum].transform.rotation, t);
         yield; 
      }  
      currPosition = posNum;
      cameraMoving = false;
}