[SOLVED] Change camera fov on mouse click (aim down sights PT2)

i would like to know how to change the camera fov with a mouse click
this is PT2 for me trying to make aim down sights, this is my A.D.S code


what i want is to make it zoom in a little bit when ads to make it a little more useful, and feel more dynamic, i want it to be an element so i can change it when i add it to the specific gun, so the fov increase will relate to the gun so the sniper zooms in more and the shotgun doesn’t zoom in as much

that make sense?

so can we do that ?

Maybe you can change the position of the camera (more forward)?

Do you mean a black screen with a hole? Like sniper games?

i already made the ads look (sniper)

i just need the fov effect i dont want to move the camera i just want to change the fov

1 Like

The camera component has a field of view property.

cameraEntity.camera.fov = 50;

so i would just add that little code to my ads code and it will work?

how would i add that as like an element
like an attribute, so when i add the script to the gun i can change the sniper fov to 30 and pistol fov to 40


ADS.attributes.add('fieldOfView', {
    type: 'number',
    default: 45


would this work?

if i put in a number will it change the fov to that number?

For that you have to change line 22 a bit.

this.cameraEntity.camera.fov = this.fieldOfView;

so replace line 17 and 22 with that exact code?

Uhm, no then it would be the same in both cases…

1 Like

fixed it, now it works perfectly

heres the finale code


go ahead and put this as solved :slight_smile: on a roll today!!! my stuff is working thank you for the help :))))))

1 Like

Thanks for the code was very helpfull :ok_hand: :grinning:

1 Like