//public PlayerAgent(LayerMask enemyHitLayerMask, LayerMask floorHitLayerMask) //{ // this.enemyHitLayerMask = enemyHitLayerMask; // this.floorHitLayerMask = floorHitLayerMask; //} #region Updates private void controllerUpdate() { verticleSpeed = Mathf.Lerp(verticleSpeed, Input.GetAxis("Vertical"), 1); horizontalSpeed = Mathf.Lerp(horizontalSpeed, Input.GetAxis("Horizontal"), 1f); // Setting Character Aiming. if (Input.GetMouseButton(1) && !m_movingAgent.isEquipingWeapon()) { m_movingAgent.aimWeapon(); } else { m_movingAgent.stopAiming(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { m_movingAgent.togglepSecondaryWeapon(); } if (Input.GetKeyDown(KeyCode.Alpha2)) { m_movingAgent.togglePrimaryWeapon(); } if (Input.GetKeyDown(KeyCode.C)) { m_movingAgent.toggleHide(); } if (Input.GetKeyDown(KeyCode.Space)) { m_movingAgent.dodgeAttack(getDirectionRelativeToCamera(new Vector3(verticleSpeed, 0, -horizontalSpeed))); } if (Input.GetKey(KeyCode.LeftShift)) { speedModifyVale = Mathf.Lerp(speedModifyVale, 2, 0.1f); m_movingAgent.moveCharacter(getDirectionRelativeToCamera(new Vector3(verticleSpeed * speedModifyVale, 0, -horizontalSpeed * speedModifyVale))); } else { speedModifyVale = Mathf.Lerp(speedModifyVale, 1f, 0.1f); m_movingAgent.moveCharacter(getDirectionRelativeToCamera((new Vector3(verticleSpeed, 0, -horizontalSpeed)).normalized * speedModifyVale)); } if (Input.GetKeyDown(KeyCode.R)) { m_movingAgent.reloadWeapon(); } UpdateShooting(); UpdateTargetPoint(); }
private void updateMove() { m_navMeshAgent.SetDestination(enemy.transform.position + new Vector3(tempFloat, 0, tempFloat2)); m_navMeshAgent.updateRotation = false; if (!m_navMeshAgent.pathPending) { Vector3 velocity = m_navMeshAgent.desiredVelocity; velocity = new Vector3(velocity.x, 0, velocity.z); m_movingAgent.moveCharacter(velocity); } }
protected void updateSelfAgentFromInput() { #region get control input float inputHorizontal = SimpleInput.GetAxis("Horizontal"); float inputVertical = SimpleInput.GetAxis("Vertical"); float aimInputHorizontal = SimpleInput.GetAxis("HorizontalAim"); float aimInputVertical = SimpleInput.GetAxis("VerticalAim"); Vector3 aimDirection = getDirectionRelativeToCamera(new Vector3(aimInputVertical, 0, -aimInputHorizontal)); bool runPressed = SimpleInput.GetButton("Run"); bool crouchPressed = SimpleInput.GetButtonDown("Crouch"); bool dodge = SimpleInput.GetButtonDown("Dodge"); bool rifle = SimpleInput.GetButtonDown("Rifle"); bool pistol = SimpleInput.GetButtonDown("Pistol"); #endregion #region control agent from input #region movment control if (rifle) { m_selfAgent.togglePrimaryWeapon(); } if (pistol) { m_selfAgent.togglepSecondaryWeapon(); } if (crouchPressed) { m_selfAgent.toggleHide(); m_crouched = !m_crouched; } if (dodge) { m_selfAgent.dodgeAttack(getDirectionRelativeToCamera((new Vector3(inputVertical, 0, -inputHorizontal).normalized) * 1.5f)); } if (runPressed) { if (m_selfAgent.isCrouched()) { m_selfAgent.toggleHide(); } m_selfAgent.moveCharacter(getDirectionRelativeToCamera((new Vector3(inputVertical, 0, -inputHorizontal).normalized) * 1.5f)); } else { if (m_crouched && !m_selfAgent.isCrouched()) { m_selfAgent.toggleHide(); } m_selfAgent.moveCharacter(getDirectionRelativeToCamera(new Vector3(inputVertical, 0, -inputHorizontal).normalized)); } #endregion #region aiming and fire control if (aimDirection.normalized.magnitude > 0) { m_selfAgent.aimWeapon(); m_targetFinder.updateTargetFinder(aimDirection, this.transform.position); m_selfAgent.setTargetPoint(m_targetFinder.getCalculatedTargetPosition()); if (m_targetFinder.canFireAtTargetAgent()) { m_selfAgent.pullTrigger(); } else { m_selfAgent.releaseTrigger(); } } else { m_selfAgent.stopAiming(); m_selfAgent.releaseTrigger(); m_targetFinder.disableTargetIndicator(); } #endregion #endregion }