I am working on a basic fight sim for a very early plane and flowing Chris DeLeon very good tutorial and I have it running with by own plane and terrain .
I now would like to change the propeller ( I know i spelt it wrong in the script ) from the static wooden object to the prop1blur object when i hit the Q key and back again for the O key .
the script below runs but the propeller doesn’t change , I linked the objects in the script in the inspector but they just stay the way they are active when I start the script .
No idea why .
I have view many tuts but clearly don’t get it , as none are exactly what i need .
thanks Ruck
using UnityEngine;
using System.Collections;
public class birdControllor : MonoBehaviour {
public float speed;
public float roll;
public float lift;
public GameObject propellar;
public GameObject prop1blur;
// Use this for initialization
void Start () {
speed = 0;
roll = 30;
lift = 30;
}
// Update is called once per frame
void Update () {
#region Horizontal Rotation
if (Input.GetAxis ("Horizontal") < 0)
transform.Rotate (0, 0, roll * Time.deltaTime);
else if (Input.GetAxis ("Horizontal") > 0)
transform.Rotate (0, 0, -roll * Time.deltaTime);
#endregion
#region Vertical (X) Axis Rotation
if (Input.GetAxis ("Vertical") < 0)
transform.Rotate (lift * Time.deltaTime, 0, 0);
else if (Input.GetAxis ("Vertical") > 0)
transform.Rotate (-lift * Time.deltaTime, 0, 0);
#endregion
transform.Translate (0, 0, speed * Time.deltaTime);
//this is a hard wired connection to the "F5" Key on the keyboard, switch it any keyboard key if you like
//this will disable the camera inside of the car, and enable the camera outside of the vehicle
if (Input.GetKey (KeyCode.Q))
speed = speed + 2;
prop1blur.SetActive(true);
propellar.SetActive(false);
//this is a hard wired connection to the "F6" Key on the keyboard, switch it any keyboard key if you like
//this will disable the camera behind the car, and enable the camera inside of the vehicle
if (Input.GetKey (KeyCode.E))
speed = speed - 2;
if (Input.GetKey (KeyCode.O))
speed = 0;
prop1blur.SetActive(false);
propellar.SetActive(true);
}
}