コード例 #1
0
 void Start()
 {
     component_CameraLook = transform.GetChild(0).gameObject.GetComponent <FPS_CameraLook>();
     component_Jump       = GetComponent <FPS_Jump>();
     component_Locomotion = GetComponent <FPS_Locomotion>();
     component_Crouch     = GetComponent <FPS_Crouch>();
 }
コード例 #2
0
    void Start()
    {
        LocomotionModule = GetComponent <FPS_Locomotion>();                      //assign GetComponent() calls to our previously declared variables
        JumpModule       = GetComponent <FPS_Jump>();
        CapsuleModule    = GetComponent <CapsuleCollider>();

        fps_camera = LocomotionModule.fps_camera;                                                            //FPS_Locomotion has already defined fps_camera variable, so we're going to store it here

        camera_initPos   = fps_camera.transform.localPosition;                                               //store player's camera LOCAL position (because our player camera is the child of player object, we must store and modify only LOCAL position)
        camera_crouchPos = new Vector3(camera_initPos.x, camera_initPos.y - crouchAmount, camera_initPos.z); //based on camera's initial LOCAL position, we calculate and store the position of the camera when player crouches
    }
コード例 #3
0
    void Awake()
    {
        fps_camera = transform.GetChild(0).gameObject;                  //assign player's first child as a camera

        currentSpeed = walkSpeed;                                       //because the game has just started set current speed to the walk speed

        //start assigning Component Calls to
        RigidbodyModule = GetComponent <Rigidbody>();
        JumpModule      = GetComponent <FPS_Jump>();
        CrouchModule    = GetComponent <FPS_Crouch>();
        ClimbModule     = GetComponent <FPS_Climb>();
        CameraModule    = fps_camera.GetComponent <FPS_CameraLook>();

        //check whether or not scripts are missing. features are going to be disabled accordingly
        jumpEnabled   = (JumpModule != null);
        crouchEnabled = (CrouchModule != null);
        climbEnabled  = (ClimbModule != null);
    }