public virtual void StartAgent() { if (agent != null && agentState != GamePlayerNavMeshAgentState.PURSUE) { agentState = GamePlayerNavMeshAgentState.PURSUE; agent.StartAgent(); NavigateToDestination(); } }
// Update is called once per frame public virtual void Update() { if (!gameObjectTimer.IsTimerPerf( GameObjectTimerKeys.gameUpdateAll, 1f)) { //return; } if (!GameConfigs.isGameRunning) { return; } //base.Update(); if (controllerData.removing) { return; } if (getUserInput) { if (Input.GetButtonDown("Jump")) { lastJumpButtonTime = Time.time; } if (Input.GetButtonDown("Slide")) { lastSlideButtonTime = Time.time; } } else { if (jumpButton) { lastJumpButtonTime = Time.time; } if (slideButton) { lastSlideButtonTime = Time.time; } } UpdateSmoothedMovementDirection(); // Apply gravity // - extra power jump modifies gravity // - capeFly mode modifies gravity ApplyGravity(); // Perform a wall jump logic // - Make sure we are jumping against wall etc. // - Then apply jump in the right direction) if (canWallJump) { ApplyWallJump(); } // Apply jumping logic ApplyJumping(); ApplySliding(); ApplyAttack(); // Calculate actual motion Vector3 movement = moveDirection * (moveSpeed * (1 - verticalInput2 / 10)) + new Vector3(0, verticalSpeed, 0) + inAirVelocity; movement *= Time.deltaTime; // Move the controller CharacterController controller = GetComponent <CharacterController>(); wallJumpContactNormal = Vector3.zero; //if(!isNetworked) { collisionFlags = controller.Move(movement); //} // Set rotation to the move direction if (IsGrounded() && moveDirection != Vector3.zero) { transform.rotation = Quaternion.LookRotation(moveDirection); } else { var xzMove = movement; xzMove.y = 0; if (xzMove.magnitude > 0.001) { transform.rotation = Quaternion.LookRotation(xzMove); } } // We are in jump mode but just became grounded if (IsGrounded()) { lastGroundedTime = Time.time; inAirVelocity = Vector3.zero; // turn on agent now we are on the mesh navMeshAgent.StartAgent(); if (jumping) { jumping = false; SendMessage("land", SendMessageOptions.DontRequireReceiver); JumpStop(); } if (sliding) { sliding = false; SendMessage("land", SendMessageOptions.DontRequireReceiver); SlideStop(); } } }