Hi I’m creating a FPS in unity3d. For my gun I used a GUITexture of my model to rid all collision troubles. And while working on my zoom feature, I encountered a problem. I have my code so the field of view is modified with the scroll wheel on the mouse, then with a if statement I check the current field of view, if it is bellow 50 then I would like it to turn off my GUITexture of the gun, and turn on my GUITexture of a scope. What command would I use to turn this on and off? Noted I’m in a script not attached to the GUITexture. Thank you (:
Hi,
maybe this simple script will work for you.
using UnityEngine;
using System.Collections;
public class GunGUIBehaviour : MonoBehaviour {
public GUITexture guiTextureGun;
public GUITexture guiTextureScope;
public float fov = 100;
void Update ()
{
if (fov < 50)
{
guiTextureGun.enabled = false;
guiTextureScope.enabled = true;
}
else
{
guiTextureGun.enabled = true;
guiTextureScope.enabled = false;
}
}
}
Best Regards
Jona