Greetings everyone,
I am completely new to Unity (or just coding in general) and am trying to make a mecha game.
One part of this mecha game is that I’m trying to build a system where it’s possible to switch between 3 points of view:
- Standard 3rd person mode,
- Standard 1st person mode, and
- Aim Down Sight mode, only when the weapon is equipped with a scope.
The problem regarding to this is that, with some googlefu I can figure out a general idea of how to switch between modes (very likely not correct as depicted below);
public GameObject ThirdCam;
public GameObject FirstCam;
public GameObject ScopeCam;
public int CamMode;
void Update() {
if(Input.GetButtonDown("Camera"))
if(CamMode==2){CamMode = 0;}else{CamMode+-=1;}
if(CamMode>2 and CamMode<0){CamMode=0)}
}
IEnumerator CamChange(){
yield return new WaitForSeconds(0.01f);
if (CamMode==0){
ThirdCam.SetActive(true);
FirstCam.SetActive(false);
ScopeCam.SetActive(false);
if (CamMode==1)
ThirdCam.SetActive(false);
FirstCam.SetActive(true);
ScopeCam.SetActive(false);
if (CamMode==2)
ThirdCam.SetActive(false);
FirstCam.SetActive(false);
ScopeCam.SetActive(true);
}
But if I want to ensure ScopeCam is possible only if the player has a weapon that is equipped with ScopeCam, how do I detect whenever ScopeCam is equipped and allow ScopeCam view to be true, and vice versa?