- Home /
Unity Editor Like Camera Script?
Hello! I am currently trying to look for a script like the unity editor camera.
Right-click to move the camera left, right, up, and down.
Scroll wheel up and down zooms in and out.
The left mouse allows the player to select the object (useless pretty much because I can make it where they can select something).
F focuses on the item they have selected.
If someone can find this for me please let me know!
Answer by DCordoba · Apr 26, 2019 at 05:19 AM
Hello @BlazingTank , you're asking for someone to do the script for you? if thats not the case, you will find, I think, this info enough to solve it by yourself
transfom of the current camera can be accessed trough the Camera.main.transform
right click can be read with Input.getMouseButton(1), after read a click you can add the Input.GetAxis("Mouse X") and "Mouse Y" to the camera.main.transform.Rotate(),
zoom can be done using Camera.main.fieldOfView, and you can read the wheel using Input.mouseScrollDelta another (completely different and most useful) way to do it, is move the camera forward, with Camera.main.transform.position += camera main transform.forward*index, manage index with the mouseScrollDelta ofc
you can manage the click objects cheking with raycast or manage this with OnMouseDown()events on each script, more complicated I think, on this case, because you need the script manager of that event inside each object, on other cases. like perform some behaviour on each object cliked, is most useful.
you can read the F key with Input.GetKeyDown(KeyCode.F) anddo the "focus" with Camera.Main.transform.LookAt(Objetive), set objetive properly with the previous command, selecting that...
ofcourse everything need to be done inside the update function, and I suggest to multiply all the indexes of the camera movement by Time.DeltaTime in order to archieve a smooth movement having a very variable framerrate
hope this help you to reach the solution, good luck
Your answer
Follow this Question
Related Questions
How to make my Camera Controller look at target 0 Answers
Having Trouble animating camera at start of game 0 Answers
Free camera look question 2 Answers