void Start()
    {
        instance = this;
        pfc      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFlightControl>();


        //Uncomment for Unity 5 to get rid of the warnings.
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        //Screen.lockCursor = true;


        deadzone_rect = new Rect((Screen.width / 2) - (deadzone_radius), (Screen.height / 2) - (deadzone_radius), deadzone_radius * 2, deadzone_radius * 2);

        if (pointerTexture == null)
        {
            Debug.LogWarning("(FlightControls) Warning: No texture set for the custom pointer!");
        }

        if (use_gamepad_input == false && use_mouse_input == false)
        {
            Debug.LogWarning("Select Input System");
        }
    }
    void Start()
    {
        cp = Camera.main.gameObject.GetComponent <CustomPointer>();

        instance = this;

        mousePos = new Vector2(0, 0);
        DZ       = cp.deadzone_radius;

        roll = 0;         //Setting this equal to 0 here as a failsafe in case the roll axis is not set up.

        //Error handling, in case one of the inputs aren't set up.
        try {
            //Input.GetAxis("Thrust");
            thrustAction.ReadValue <double>();
            print(thrustAction.ReadValue <double>());
        }
        catch {
            thrust_exists = false;
            Debug.LogError("(Flight Controls) Thrust input axis not set up! Go to Edit>Project Settings>Input to create a new axis called 'Thrust' so the ship can change speeds.");
        }

        try {
            //Input.GetAxis("Roll");
            rollAction.ReadValue <double>();
            print(rollAction.ReadValue <double>());
        } catch {
            roll_exists = false;
            Debug.LogError("(Flight Controls) Roll input axis not set up! Go to Edit>Project Settings>Input to create a new axis called 'Roll' so the ship can roll.");
        }
    }
Beispiel #3
0
    void SetupPlayer(Player player)
    {
        CameraFlightFollow  cameraFlight = Instantiate(playerCameraPrefab, transform, true);
        PlayerFlightControl flight       = player.GetComponent <PlayerFlightControl>();

        player.CameraFlight      = cameraFlight;
        player.hitScanner        = cameraFlight.GetComponent <HitScanner>();
        player.hitScanner.player = player;

        cameraFlight.SetPlayerFlightControl(flight);
    }
    public override void OnInspectorGUI()
    {
        PlayerFlightControl flightCC = (PlayerFlightControl)target;

        EditorGUILayout.Separator();
        GUILayout.Label(new GUIContent("Objects", "For the main ship Game Object and weapons"));

        flightCC.actual_model = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Ship Game Object", "Point this to the Game Object that actually contains the mesh for the ship. Generally, this is the first child of the empty container object this controller is placed in."), flightCC.actual_model, typeof(GameObject), true);
        if (flightCC.bullet != null)
        {
            flightCC.bullet = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Projectile Game Object", "Projectile that will be fired from the weapon hardpoint."), flightCC.bullet, typeof(GameObject), true);
        }

        //new GUIContent("", "")
        EditorGUILayout.Separator();
        GUILayout.Label(new GUIContent("Core Movement", "Controls for the various speeds for different operations."));

        flightCC.speed                   = EditorGUILayout.FloatField(new GUIContent("Base Speed", "Primary flight speed, without afterburners or brakes"), flightCC.speed);
        flightCC.slow_speed              = EditorGUILayout.FloatField(new GUIContent("Brake Speed", "Speed when the button for negative thrust is being held down"), flightCC.slow_speed);
        flightCC.afterburner_speed       = EditorGUILayout.FloatField(new GUIContent("Afterburner Speed", "Speed when the button for positive thrust is being held down"), flightCC.afterburner_speed);
        flightCC.thrust_transition_speed = EditorGUILayout.FloatField(new GUIContent("Thrust Transition Speed", "How quickly afterburners/brakes will reach their maximum effect"), flightCC.thrust_transition_speed);
        flightCC.turnspeed               = EditorGUILayout.FloatField(new GUIContent("Turn/Roll Speed", "How fast turns and rolls will be executed"), flightCC.turnspeed);
        flightCC.rollSpeedModifier       = EditorGUILayout.FloatField(new GUIContent("Roll Speed", "Multiplier for roll speed. Base roll is determined by turn speed"), flightCC.rollSpeedModifier);
        flightCC.pitchYaw_strength       = EditorGUILayout.FloatField(new GUIContent("Pitch/Yaw Multiplier", "Controls the intensity of pitch and yaw inputs"), flightCC.pitchYaw_strength);

        EditorGUILayout.Separator();

        GUILayout.Label(new GUIContent("Banking", "Visuals only--has no effect on actual movement"));


        flightCC.use_banking = EditorGUILayout.BeginToggleGroup(new GUIContent("Use Banking", "The ship will bank when doing turns."), flightCC.use_banking);

        flightCC.bank_rotation_speed      = EditorGUILayout.FloatField(new GUIContent("Bank Rotation Speed", "Rotation speed along the Z axis when yaw is applied. Higher values will result in snappier banking."), flightCC.bank_rotation_speed);
        flightCC.bank_rotation_multiplier = EditorGUILayout.FloatField(new GUIContent("Bank Rotation Multiplier", "Bank amount along the Z axis when yaw is applied."), flightCC.bank_rotation_multiplier);
        flightCC.bank_angle_clamp         = EditorGUILayout.FloatField(new GUIContent("Bank Angle Clamp", "Maximum angle the spacecraft can rotate along the Z axis."), flightCC.bank_angle_clamp);
        EditorGUILayout.EndToggleGroup();


        EditorGUILayout.Separator();

        flightCC.screen_clamp = EditorGUILayout.FloatField(new GUIContent("Screen Clamp (Pixels)", "Once the pointer is more than this many pixels from the center, the input in that direction(s) will be treated as the maximum value."), flightCC.screen_clamp);
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     // Getting compoment
     player = FindObjectOfType <PlayerFlightControl>();
 }
Beispiel #6
0
 // Calling the player for targetting
 void Start()
 {// Getting the component to use in file
     rb     = GetComponent <Rigidbody>();
     target = GameObject.FindObjectOfType <PlayerFlightControl>();
 }
 public void SetPlayerFlightControl(PlayerFlightControl control)
 {
     this.control = control;
     player       = control.GetComponent <Player>();
 }