// Update is called once per frame void Update() { if (PauseScreen.shouldPause(PAUSE_LEVEL)) { return; } //sets m_CanGrapple to true when the players lands on the ground, this is necessary so the player can not keep grappling without ever touching the //ground. if (GetIsGrounded()) { m_CanGrapple = true; } if (m_PlayerHealth.IsDead) { m_target.SetCurrentTarget(null); m_Grappling = false; m_CanGrapple = false; } //checks if there is a target in sight if (m_target.GetCurrentTarget() != null && m_Grappling == false) { //checks if player is on ground, he can't grapple if on ground if (CanGrapple()) { //Checks for input, if jump has been pressed then m_Grappling = true; if (InputManager.getJumpDown(m_AcceptInputFrom.ReadInputFrom) && m_PlayerHealth.IsDead != true) { m_Grappling = true; m_CanGrapple = false; m_GrappleHook.renderer.enabled = true; m_CurrentTarget = m_target.GetCurrentTarget(); } } } //checks the distance between the player and the target, if it's smaller than m_DistBeforeFalling, you will fall if (m_CurrentTarget != null) { if (Vector3.Distance(this.transform.position, m_CurrentTarget.transform.position) < m_DistBeforeFalling) { m_Grappling = false; m_GrappleHook.renderer.enabled = false; } } //if you should be grappling move to your target if (m_Grappling) { PlayAnimation(); MoveTowardsTarget(); SetGrappleTransform(); return; } //Used to make sure that the player stops trying to grapple if his target gets destroyed if (m_target.GetCurrentTarget() == null) { m_Grappling = false; } base.UpdateVelocity(); }