Here is the code in C#:
The problem line is:
if (Idle)
{
air_pressure.active=false;
front_fins.transform.Rotate(0, 0, 0);
rear_fins.transform.Rotate(0, 0, 0);
***This is where I try to set the wings to their original position which is exactly 0,0,0
}
//FA-37 TALON JET CONTROLLER
//SEE FA-37 WEAPON CONTROLLER SCRIPT FOR THE WEAPONS
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TalonControl : MonoBehaviour {
public GameObject talon;
public GameObject thrust;
public GameObject engine;
public GameObject vtol_jet;
public GameObject air_pressure;
public GameObject cockpitcam;
public GameObject rearcam;
public GameObject cinecam;
public GameObject front_fins;
public GameObject rear_fins;
public GameObject rear_rudder1;
public GameObject rear_rudder2;
public GameObject gears;
public bool PitchUp = false;
public bool PitchDown = false;
public bool TurnLeft = false;
public bool TurnRight = false;
public bool RollLeft = false;
public bool RollRight = false;
public bool FlyUp = false;
public bool FlyDown = false;
public bool Idle = false;
public float vtol = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (vtol<=0){
talon.transform.Translate(Vector3.forward * 20 * Time.deltaTime);
vtol_jet.active=false;
thrust.active=true;
gears.active=false;
}
if (vtol>=1){
talon.transform.Translate(Vector3.forward * 0 * Time.deltaTime);
vtol_jet.active=true;
thrust.active=false;
gears.active=true;
}
if (FlyUp)
{
talon.transform.Translate(Vector3.up * 5 * Time.deltaTime);
}
if (FlyDown)
{
talon.transform.Translate(Vector3.down * 5 * Time.deltaTime);
}
if (PitchUp)
{
talon.transform.Rotate(Vector3.left, 20 * Time.deltaTime);
front_fins.transform.Rotate(Vector3.left, 100 * Time.deltaTime);
rear_fins.transform.Rotate(Vector3.right, 100 * Time.deltaTime);
air_pressure.active=true;
}
if (PitchDown)
{
talon.transform.Rotate(Vector3.right, 20 * Time.deltaTime);
front_fins.transform.Rotate(Vector3.right, 100 * Time.deltaTime);
rear_fins.transform.Rotate(Vector3.left, 100 * Time.deltaTime);
air_pressure.active=true;
}
if (TurnLeft)
{
talon.transform.Rotate(Vector3.down, 20 * Time.deltaTime);
}
if (TurnRight)
{
talon.transform.Rotate(Vector3.up, 20 * Time.deltaTime);
}
if (RollLeft)
{
talon.transform.Rotate(Vector3.forward, 20 * Time.deltaTime);
}
if (RollRight)
{
talon.transform.Rotate(-Vector3.forward, 20 * Time.deltaTime);
}
// PROBLEM
if (Idle)
{
air_pressure.active=false;
front_fins.transform.Rotate(0, 0, 0);
rear_fins.transform.Rotate(0, 0, 0);
}
//PROBLEM
}
public void Vtol1()
{
vtol=1;
}
public void Vtol0()
{
vtol=0;
}
public void Cockpit()
{
cockpitcam.active=true;
rearcam.active=false;
cinecam.active=false;
engine.active=false;
}
public void Rear()
{
cockpitcam.active=false;
rearcam.active=true;
cinecam.active=false;
engine.active=true;
}
public void Cine()
{
cockpitcam.active=false;
rearcam.active=false;
cinecam.active=true;
engine.active=true;
FlyUp=false;
FlyDown=false;
}
public void onPitchUp()
{
PitchUp=true;
PitchDown=false;
TurnLeft=false;
TurnRight=false;
RollLeft=false;
RollRight=false;
FlyUp=false;
FlyDown=false;
Idle=false;
}
public void onPitchDown()
{
PitchUp=false;
PitchDown=true;
TurnLeft=false;
TurnRight=false;
RollLeft=false;
RollRight=false;
FlyUp=false;
FlyDown=false;
Idle=false;
}
public void onTurnLeft()
{
PitchUp=false;
PitchDown=false;
TurnLeft=true;
TurnRight=false;
RollLeft=false;
RollRight=false;
FlyUp=false;
FlyDown=false;
Idle=false;
}
public void onTurnRight()
{
PitchUp=false;
PitchDown=false;
TurnLeft=false;
TurnRight=true;
RollLeft=false;
RollRight=false;
FlyUp=false;
FlyDown=false;
Idle=false;
}
public void onIdle()
{
PitchUp=false;
PitchDown=false;
TurnLeft=false;
TurnRight=false;
RollLeft=false;
RollRight=false;
FlyUp=false;
FlyDown=false;
Idle=true;
}
public void onRollLeft()
{
PitchUp=false;
PitchDown=false;
TurnLeft=false;
TurnRight=false;
RollLeft=true;
RollRight=false;
FlyUp=false;
FlyDown=false;
Idle=false;
}
public void onRollRight()
{
PitchUp=false;
PitchDown=false;
TurnLeft=false;
TurnRight=false;
RollLeft=false;
RollRight=true;
FlyUp=false;
FlyDown=false;
Idle=false;
}
public void onFlyUp()
{
PitchUp=false;
PitchDown=false;
TurnLeft=false;
TurnRight=false;
RollLeft=false;
RollRight=false;
FlyUp=true;
FlyDown=false;
Idle=false;
}
public void onFlyDown()
{
PitchUp=false;
PitchDown=false;
TurnLeft=false;
TurnRight=false;
RollLeft=false;
RollRight=false;
FlyUp=false;
FlyDown=true;
Idle=false;
}
}
