I have this code, which is to operate the mouse sensitivity when either of these cameras are zoomed in. I have a third camera which is a 3rd person camera and if I goto that camera from one of the other cameras while it is zoomed the mouse sensitivity stays at the zoomed in sensitivity, which I do not want. So I used the input to goto the 3rd person camera to put the sensitivity back to normal, but it doesn’t work. Although it does work for the GetButton, but not the GetButtonDown.
/
/
/
function ZoomSens()
{
if(Input.GetKeyDown("z"))
{
isZoomed = !isZoomed;
}
if(isZoomed == true)
{
MouseSensitivity = zoomSen;
BarrelReticule.guiTexture.active = false;
TIS10X.guiTexture.active = true;
TIS3X.guiTexture.active = false;
TIScamera.fieldOfView = Mathf.Lerp(TIScamera.fieldOfView,zoom,Time.deltaTime*smooth);
}
else
{
MouseSensitivity = normalSen;
BarrelReticule.guiTexture.active = true;
TIS3X.guiTexture.active = true;
TIS10X.guiTexture.active = false;
TIScamera.fieldOfView = Mathf.Lerp(TIScamera.fieldOfView,normal,Time.deltaTime*smooth);
}
If(Input.GetButtonDown("ThirdPerson"))
{
MouseSensitivity = normalSen;
}
}
/
/
/
I am in the process of using one camera for all of these, I just want to understand why the function won’t work.
No ideas why this isn’t working???
This script isn’t the reason it’s not working. If zoomSen is not static, then it applies to each camera seperately, and it may cause conflicts between two different values for zoomSen trying to manipulate the sensitivity. Your problem is logical, not syntactic, and the logic isn’t displayed on the above script.
Do what you were already going to do. Use only one camera with only one instance of this script and have that script alone control the sensitivity. Instead of switching cameras, simply reposition the existing one.
It has nothing to do with the cameras though.
I have to lower the sensitivity when the camera is zoomed for obvious reasons, so I have it change when the zoom input is hit, and when the camera is basically unzoomed it goes back to the normal sensitivity.
The issue is, If I goto the thirdperson camera from the zoomed function it stays at the zoomed sensitivity, I can hit the zoom key again which brings it back to normal, but it would be better to just put it to normal on going to the main camera.
Everything is in this code. I just don’t get why the input code won’t work for switching it to normal sensitivity.
Why isn’t this working??
/
/
/
1./
2./
3./
4.function ZoomSens()
5.
6. {
7.
8. if(Input.GetKeyDown("z"))
9.
10. {
11.
12. isZoomed = !isZoomed;
13.
14. }
15.
16. if(isZoomed == true)
17.
18. {
19.
20. MouseSensitivity = zoomSen;
21.
22. BarrelReticule.guiTexture.active = false;
23.
24. TIS10X.guiTexture.active = true;
25.
26. TIS3X.guiTexture.active = false;
27.
28. TIScamera.fieldOfView = Mathf.Lerp(TIScamera.fieldOfView,zoom,Time.deltaTime*smooth);
29.
30. }
31.
32. else
33.
34. {
35.
36. MouseSensitivity = normalSen;
37.
38. BarrelReticule.guiTexture.active = true;
39.
40. TIS3X.guiTexture.active = true;
41.
42. TIS10X.guiTexture.active = false;
43.
44. TIScamera.fieldOfView = Mathf.Lerp(TIScamera.fieldOfView,normal,Time.deltaTime*smooth);
45.
46. }
47. If(Input.GetButtonDown("ThirdPerson"))
48. {
49. MouseSensitivity = normalSen;
50. }
51.}
52./
53./
54./
I can not see where you are applying this to the mouse sensitivity. The actual function manipulating the mouse. All I can see is you setting bools.
Its just -
var MouseSensitivity : Vector3 = Vector3(15,15,5);
That is normal? What about non normal or zoomed?
/
/
/
var zoom : int = 20;
var normal : int = 60;
var smooth : float = 5;
var TIS3X : GameObject;
var TIS10X : GameObject;
var TIScamera : Camera;
private var isZoomed = false;
var normalSen : Vector3;
var zoomSen : Vector3;
function ZoomSens()
{
if(Input.GetKeyDown("z"))
{
isZoomed = !isZoomed;
}
if(isZoomed == true)
{
MouseSensitivity = zoomSen;
BarrelReticule.guiTexture.active = false;
TIS10X.guiTexture.active = true;
TIS3X.guiTexture.active = false;
TIScamera.fieldOfView = Mathf.Lerp(TIScamera.fieldOfView,zoom,Time.deltaTime*smooth);
}
else
{
MouseSensitivity = normalSen;
BarrelReticule.guiTexture.active = true;
TIS3X.guiTexture.active = true;
TIS10X.guiTexture.active = false;
TIScamera.fieldOfView = Mathf.Lerp(TIScamera.fieldOfView,normal,Time.deltaTime*smooth);
}
}
/
/
/
and what is MouseSensititvty? How are you applying that to anything to do with the mouse?
MouseSensititvty is the above var that is the default setting, when I goto a different camera position I need to be able to zoom it and when I hit the key to goto that other position then zoom it changes the sensitivity to a lower setting and works fine, but If I goto the default 3rd person position from a zoomed state that has the lower sensitivity set it doesn’t goto the normal sensitivity, which the GetButtonDown(“ThirdPerson”) function should do, but it isn’t working.
Well that chunk is missing from your last post.
7. If(Input.GetButtonDown("ThirdPerson"))
48. {
49. MouseSensitivity = normalSen;
50. }
Anyhow, beyond that, I am just failing to see how you are applying this to your mouse. Maybe that is not the issue. If normalSen is what will set your mouse sensitivity accordingly then it should work. Perhaps, you are missing something somewhere. I would use a lot of print calls in each function so you can check the status of mouse sensitively in any stage.
Yeah I took that chunk out…lol, because it wasn’t working. It works if I use the GetButton, but thats not what I want.
I am using the inspector to see if it is changing or not and it isn’t. I just don’t get why this will not work. If I am missing something, I’m sure one of you would have spotted it by now.
I’m stumped
I would do this, Just run a invokeRepeating or in update, just print off the status of mouseSensitivity. Also place prints in each function so you know when you hit it ( changed states etc ) . By that, you can study your inputs and what states were changed to what. Hopefully that will give you clues Watson!
I have never used prints to debug,
just …
function this()
{
print(“mouseSensitivity” + mouseSensitivity);
}
function inputSomething()
{
print(“we just inputed something, mouse sensitivity might be different”);
}
and read it in the console.
It says its what it should be but int he inspector it still shows the lowered setting…
Yeah, when I zoom it lowers the sesitivity so it isn’t all sensitive, the zoomsen is (2,2,2) the normsen is (15,15,5)
I have tried everything to get it to switch back to normsen, nothing is working…
so it switched zoomsen once, but not back?
And what is triggering in and out zoom sen? From normal at start, you hit what to get zoomsen. Then from zoomed in to out, Where the trouble is, you hit what?