protected void Start() { // Cache component references _characterController = GetComponent <CharacterController>(); _controllerHeight = _characterController.height; // Get the main camera and cache local position within the FPS rig _camera = Camera.main; _localSpaceCameraPos = _camera.transform.localPosition; // Set initial to not jumping and not moving _movementStatus = PlayerMoveStatus.NotMoving; // Reset timers _fallingTimer = 0.0f; // Setup Mouse Look Script _mouseLook.Init(transform, _camera.transform); // Initiate Head Bob Object _headBob.Initialize(); _headBob.RegisterEventCallback(1.5f, PlayFootStepSound, CurveControlledBobCallbackType.Vertical); if (_flashLight) { _flashLight.SetActive(false); } }
protected void Start() { _characterController = GetComponent <CharacterController>(); _controllerHeight = _characterController.height; _camera = Camera.main; _localSpaceCameraPos = _camera.transform.localPosition; _movementStatus = PlayerMoveStatus.NotMoving; _fallingTimer = 0.0f; //初始化MouseLook脚本 _mouseLook.Init(transform, _camera.transform); _headBob.Initialize(); _headBob.RegisterEventCallback(1.5f, PlayFootStepSound, CurveControlledBobCallbackType.Vertical); if (_flashLight) { _flashLight.SetActive(false); } }
void Start() { _characterController = GetComponent <CharacterController>(); _camera = Camera.main; // Setup mouse look script _mouseLook.Init(transform, _camera.transform); _localSpaceCameraPos = _camera.transform.localPosition; _headBob.Initialize(); _headBob.RegisterEventCallback(1.5f, PlayerFootStepSound, CurveControlledBobCallbackType.Vertical); if (_flashLight) { _flashLight.SetActive(_flashLightOnAtStart); } _characterControllerHeight = _characterController.height; }
protected void Start() { characterController = GetComponent <CharacterController>(); _controllerHeight = characterController.height; _camera = Camera.main; _localSpaceCameraPos = _camera.transform.localPosition; _movementStatus = PlayerMoveStatus.NotMoving; _fallingTimer = 0; _mouseLook.Init(transform, _camera.transform); _headBob.Initialize(); if (_flashLight) { _flashLight.SetActive(false); } }
//functions protected void Start() { _characterController = GetComponent <CharacterController>(); _controllerHeight = _characterController.height; //searches for camera with main camera tag _camera = Camera.main; _localSpaceCameraPos = _camera.transform.localPosition; print(_localSpaceCameraPos); _movementStatus = PlayerMoveStatus.NOTMOVING; _fallingTimer = 0.0f; _mouseLook.Init(transform, _camera.transform); _headBob.Initialize(); _headBob.RegisterEventCallback(1.5f, PlayFootstepSound, CurveControlledBobCallbackType.VERTICAL); if (_flashLight) { _flashLight.SetActive(false); } }
protected override void Start() { base.Start(); m_InputActions.Enable(); m_MoveAction = m_InputActions["Player/Move"]; m_RunAction = m_InputActions["Player/Run"]; m_LookAction = m_InputActions["Player/Look"]; m_JumpAction = m_InputActions["Player/Jump"]; m_FlyAction = m_InputActions["Player/Fly"]; m_FlyDownAction = m_InputActions["Player/Fly Down"]; m_CursorStateAction = m_InputActions["Player/Cursor State"]; m_Camera = GetComponentInChildren <Camera>(); m_CameraTransform = m_Camera.GetComponent <Transform>(); m_FluidInteractor = GetComponent <FluidInteractor>(); m_FirstPersonLook.Initialize(m_Transform, m_CameraTransform, true); m_HeadBob.Initialize(m_CameraTransform); m_JumpBob.Initialize(); m_OriginalCameraPosition = m_CameraTransform.localPosition; m_StepCycle = 0f; m_NextStep = m_StepCycle * 0.5f; m_RunAction.performed += SwitchRunMode; m_JumpAction.performed += SwitchJumpMode; m_FlyAction.performed += SwitchFlyMode; m_FlyDownAction.performed += SwitchFlyDownMode; m_CursorStateAction.performed += SwitchCursorState; BlockInteraction interaction = GetComponent <BlockInteraction>(); interaction.Initialize(m_Camera, this); interaction.enabled = true; }
protected void Start() { // component references characterController = GetComponent <CharacterController>(); controllerHeight = characterController.height; // Get the main camera and save its local position within the FPS rig _camera = Camera.main; localSpaceCameraPos = _camera.transform.localPosition; //every frame can generate offset frm this vector, so now rounding errors // Set movementStatus to not jumping and not moving movementStatus = PlayerMoveStatus.NotMoving; // Reset timers fallingTimer = 0.0f; // Setup Mouse Look Script. Uses MouseLook script thats already available. mouseLook.Init(transform, _camera.transform); // Initiate Head Bob Object headBob.Initialize(); //Plays footstep sound when YplayHead passes the 1.5 second mark headBob.RegisterEventCallback(1.5f, PlayFootStepSound, CurveControlledBobCallbackType.Vertical); //Make sure the game starts wuth flashlight set to inactive if (flashLight) { flashLight.SetActive(false); } //All sprites in inventory set to inactive m4Sprite.enabled = false; shotgunSprite.enabled = false; keySprite.enabled = false; endKeySprite.enabled = false; }