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
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
});
https://developer.playcanvas.com/en/user-manual/scripting/script-attributes/
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…
fixed it, now it works perfectly
go ahead and put this as solved on a roll today!!! my stuff is working thank you for the help :))))))
Thanks for the code was very helpfull