![]() Without Unity Pro, you have two alternatives:ġ- the code above, which brings the weapon to the aim position and zooms in the whole screen - only one camera is used Ģ- a two camera approach, where the zoomed image appear in the scope and the rest of the screen remain the same. ![]() Private var regPos: Vector3 private var regRot: Quaternion private var regFov: float = 60 // standard field of viewįunction Start()Ĭall Aiming(true) to aim and zoom, and Aiming(false) to return to standard position.Ī more sophisticated sniper scope would require Unity Pro: you should have the scope camera childed to the weapon and drawing to a Render Texture mapped to the scope visor - this way the image seen by the scope camera would appear only in the scope visor, and you could animate the weapon. Var aimObj: Transform // drag the aiming position game object here var duration: float = 0.6 // animation duration in seconds var zoomFov: float = 25 // set the zoomed field of view ![]() To zoom in, just change the camera's Field Of View: narrow angles zoom in, while wider angles zoom out - like this (weapon script): When aiming, Lerp the position and Slerp the rotation to the aiming object, and do the inverse path when returning to the standard position. Animation can produce more natural and realistic results, but the hard code way may be good enough since aiming is a very simple movement.Ī possible hard code way is to place an empty object at the aim position/orientation and child it to the camera.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |