- Home /
Mouse Look / Cursor
Hello All,
I am very new to Unity and scripting, but wondering if I could get some help from you guys and gals :-)
What I am trying to achieve is a camera script like the one used in Call of Duty (the 3rd person one, not a standard FPS). I would ideally then like that camera script to be applied ONLY when "equiping a weapon". When no weapon is equiped I would like to use a camera similar to WoW (which I have found a few scripts for).
In a nut-shell I would like 1 button (Ctrl for example) to switch between "passive mode" (this has WoW based camera) and "action mode" (this has CoD based camera). Is this possilbe?
As I said I am rather new to both unity and scripting so please explain as much as possible, I am very eager to learn! If anyone has links to tutorials or other online resources that would help me with this would be much appreciated!
Thank you very much for all your help in advance!
Answer by Jaap Kreijkamp · Jan 20, 2010 at 12:10 AM
A way to do it without understanding too much of scripting is create two separate camera's each doing one of the behaviours and in your player script turn on/off the right camera depending on the action you're doing. This way you can probably getting quite far with stock camera scripts found on the web. Add something like below to your player script and connect the passiveCamera/actionCamera properties with the right Cameras in the inspector. Now you have two simple functions to switch between the camera's.
var passiveCamera : Camera; var actionCamera : Camera;
function ActivatePassiveCamera() { actionCamera.gameObject.SetActiveRecursively(false); passiveCamera.gameObject.SetActiveRecursively(true); }
function ActivateActionCamera() { passiveCamera.gameObject.SetActiveRecursively(false); actionCamera.gameObject.SetActiveRecursively(true); }
Thank you very much for your response! Soon as I can I will try this out! :-)
Your answer
![](https://koobas.hobune.stream/wayback/20220612001113im_/https://answers.unity.com/themes/thub/images/avi.jpg)