|
does anyone have a script for somthing like using the scope on a sniper do i just need to do somthing like have a 2nd camera futher forward from my gun and when u press fire2/ right click it switchs camera but uses same shooting spawn point if so how would i script that camera move thing if u could id prefer the script in C# if u cant dw any type will do thankyou
(comments are locked)
|
|
You can implement whatever kind of zoom you want. If you want a dolly-style zoom, then a second camera or simply moving your main camera forward would do and likewise, even displaying a full-screen render texture of the second camera would also be a solution. If you wanted an actual perspective zoom, you would change field of view. If you were to simply check other questions using the zoom tag which you are already using, you will find several scripts already written to do exactly that. You could also check the questions tagged sniper, but that's a worse tag by far. Field of view shift would be something like:
With 2 cameras, you could swap cameras by enabling/disabling them:
As I stated, there are several different solutions, most of which discussed in the questions tagged zoom. is there a way i can make it so i can switch to the front camera but theres a string so if it hits and object infron it draws back to that and has a set distance limit of the camera thanks
Nov 02 '10 at 06:38 AM
Daniel Girgis
No, not really. You'd have to do a raycast from cam1 to cam2 to check for collision and you'd have to do it every frame to prevent something passing between your cameras. Also, unless your cameras are orthographic (in which case there's no point in zooming), this would just look wrong, especially with your camera jumping back like that. Changing field of view is actually the correct implementation of a zoom. If you need it to be a second camera for some reason, why no just have the 2 cameras in the same position/orientation (one the parent of the other), each with different field of view?
Nov 02 '10 at 02:22 PM
skovacs1
(comments are locked)
|
|
You don't need a second camera (although you may want one positioned to align with the scope/have a GUITexture drawn over it, etc. That's all up to you, though). All you need to do is have a look at the Camera class, where you can chose to either change the field of view or the camera's transform, depending on how you want the effect to look. If you search the answers site for "sniper," "fov," or "field of view" (or some permutation of the three) you'll get a lot of answers related to what you want, including this one that Jonas answered: link. thats what i was thinking of doing its just the problem that i could have my camera on the other side of objects ect if its a sniper but thanks
Nov 02 '10 at 05:25 AM
Daniel Girgis
Are you talking about having objects occlude the sniper view? If that's the case, you probably want to go with changing the FoV rather than translating your scope's camera.
Nov 02 '10 at 01:37 PM
burnumd
(comments are locked)
|
|
i made this out of the script u gave me but is there anyway of making the it actually zoom in like saying feild of view goes up by 2 every frame until it reaches a set number and vice versa sorry i got u doing all my work but im really learning thanks
(comments are locked)
|
