コード例 #1
0
 // Use this for initialization
 void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     rb  = GetComponent <Rigidbody>();
     col = GetComponent <CapsuleCollider>();
     wr  = GetComponent <WallRunning>();
 }
コード例 #2
0
    private void Start()
    {
        useGravity = true;

        wr = GetComponent <WallRunning>();
        rb = GetComponent <Rigidbody>();
        rb.freezeRotation = true;
        shooting          = GetComponent <Shooting>();

        coyoteTimer = coyoteTime;
        slideSpeed  = startSlideSpeed;
    }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        // update movespeed so equillibrium speed = expected movespeed
        WR_script    = GetComponent <WallRunning>();
        controller   = GetComponent <CharacterController>();
        slide_script = GetComponent <Sliding>();
        velocity     = new Vector3(1f, 0f, -1f);

        isWallRunning = false;
        isSliding     = false;
        isSprinting   = false;
        landed        = false;

        checkpointPos    = transform.position;
        checkpointPos.y += 1f;
    }
コード例 #4
0
 private void Start()
 {
     wr = GetComponent <WallRunning>();
     rb = GetComponent <Rigidbody>();
 }
コード例 #5
0
    private void Awake()
    {
        Player player = FindObjectOfType <Player>();

        _characterController = GetComponent <CharacterController>();
        _stateHelper         = new PlayerMovementStateMachineHelper();
        _stateMachine        = new BaseStateMachine();
        _playerLookVars      = new PlayerLookVars();

        // Hook into the BaseStateMachine OnStateChanged event
        _stateMachine.OnStateChanged += HandleStateChanged;

        // Prepare our StateParams for passing to all of our states
        _stateParams                 = new StateParams();
        _stateParams.Velocity        = _velocity;
        _stateParams.GravityOverride = defaultGravity;

        // Create our states
        Idle        idle        = new Idle(player);
        Walking     walking     = new Walking(player);
        Sprinting   sprinting   = new Sprinting(player);
        Jumping     jumping     = new Jumping(player);
        WallRunning wallRunning = new WallRunning(player, defaultGravity);
        Crouching   crouching   = new Crouching(player);
        Sliding     sliding     = new Sliding(player);

        // Create our state transitions
        // Any -> Idle
        _stateMachine.AddAnyTransition(idle, () => _stateHelper.ToIdle(idle, jumping, crouching, sliding));
        // Any -> Jumping
        _stateMachine.AddAnyTransition(jumping, () => _stateHelper.ToJump(jumping, _isWallRunning, _stateParams.WallJumped));

        // Idle -> Walking
        _stateMachine.AddTransition(idle, walking, () => walking.IsWalking());
        // Walking -> Sprinting
        _stateMachine.AddTransition(walking, sprinting, () => PlayerInput.Instance.ShiftDown);
        // Sprinting -> Walking
        _stateMachine.AddTransition(sprinting, walking, () => !sprinting.IsStillSprinting());

        // Idle -> Crouching
        _stateMachine.AddTransition(idle, crouching, () => PlayerInput.Instance.CrouchDown);
        // Walking -> Crouching
        _stateMachine.AddTransition(walking, crouching, () => PlayerInput.Instance.CrouchDown);
        // Crouching -> Walking
        _stateMachine.AddTransition(crouching, walking, () => _stateHelper.CrouchToWalk(crouching, walking));
        // Crouching -> Sprinting
        _stateMachine.AddTransition(crouching, sprinting, () => _stateHelper.CrouchToSprint(crouching));
        // Sprinting -> Sliding (Crouching)
        _stateMachine.AddTransition(sprinting, sliding, () => PlayerInput.Instance.CrouchDown);

        // Jumping -> Sliding
        _stateMachine.AddTransition(jumping, sliding, () => _stateHelper.JumpToSlide(jumping));
        // Jumping -> Sprinting
        _stateMachine.AddTransition(jumping, sprinting, () => _stateHelper.JumpToSprint(jumping, _preserveSprint));
        // Jumping -> Walking
        _stateMachine.AddTransition(jumping, walking, () => _stateHelper.JumpToWalk(jumping, walking, _preserveSprint));
        // Jumping -> Wall Running
        _stateMachine.AddTransition(jumping, wallRunning, () => _isWallRunning);

        // Wall Running -> Sprinting
        _stateMachine.AddTransition(wallRunning, jumping, () => _stateHelper.WallRunToSprint(jumping, _isWallRunning, _preserveSprint));
        // Wall Running -> Walking
        _stateMachine.AddTransition(wallRunning, jumping, () => _stateHelper.WallRunToWalk(jumping, walking, _isWallRunning));

        // Default to Idle
        _stateParams = _stateMachine.SetState(idle, _stateParams);
    }
コード例 #6
0
 private void Start()
 {
     PMS     = FindObjectOfType <PlayerMovement>();
     Jumpboy = FindObjectOfType <WallRunning>();
     InvokeRepeating("Checker", 0.1f, 0.1f);
 }