Hello Community.
Recently I started working on a FPS assassination video game. I created a scope that works with a secondary camera at the front of my scope, which targets a plane and renders with a render texture.
This issue I am facing, is I am having trouble overlaying a texture of the scope’s crosshair (the + in a sniper’s scope). I want it to display over the render texture, while still being as accurate as it can be. Please help, as I am stuck with this issue and can’t continue my project until the current issue is fixed.
The code I am using for my scope to go into the ADS mode , is as follows…
#pragma strict
var defaultFOV : int = 0;
var fovSpeed : int = 0;
var fovIn : int = 0;
var gunAim : boolean = false;
var playerCam : GameObject;
var gunModel : GameObject;
var scopeInAnim : String;
var scopeOutAnim : String;
function Start () {
defaultFOV = playerCam.camera.fieldOfView;
}
function Update () {
if(Input.GetMouseButtonDown(1)){
animation.Play(scopeInAnim);
gunAim = true;
}
if(Input.GetMouseButtonUp(1)){
animation.Play(scopeOutAnim);
gunAim = false;
}
if(gunAim){
playerCam.camera.fieldOfView = Mathf.Lerp(playerCam.camera.fieldOfView, fovIn, fovSpeed * Time.deltaTime);
}
if(!gunAim){
playerCam.camera.fieldOfView = Mathf.Lerp(playerCam.camera.fieldOfView, defaultFOV, fovSpeed * Time.deltaTime);
}
}
It’s a javascipt code, btw.
Please help, thanks in regards.
-RuSchoeman