Jump to content

Am I Writing This Correctly?


Recommended Posts

I am trying to make my own mod for first person on EVA. What am I doing incorrectly, what could I do better. I don't think I'm understanding this correctly. Thanks in advance.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace HelmetView
{
    [KSPAddon(KSPAddon.Startup.Flight, false)]
    public class HelmetView : MonoBehaviour
    {
        private bool firstPerson = false;

        public void SwitchCameraEVA(bool toFirst)
        {
            if(toFirst)
            {
                print("FIRST PERSON CAMERA STUFF");
            }
            else if(!toFirst)
            {
                print("THIRD PERSON");
                // Disable FirstPerson!
            }
        }
        public void Update()
        {
            // If Eva is true
            if (FlightGlobals.ActiveVessel.isEVA)
            {
                // Camera Perspective Change Key.
                bool switchCameraKey = Input.GetKeyDown(KeyCode.C);

                if (switchCameraKey && !firstPerson)
                {
                    // Change to 1rd Person
                    SwitchCameraEVA(true);
                    firstPerson = true;
                }
                else if(switchCameraKey && firstPerson)
                {
                    // Change to 3rd Person
                    SwitchCameraEVA(false);
                    firstPerson = false;
                }
            }
        }
    }
}

 

Edited by Carrot7
I changed the code
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...