// Update is called once per frame void Update() { // animator.SetFloat("Speed", Mathf.Abs(InputDirection)); var rigidBody = gameObject.GetComponent <Rigidbody2D>(); this.ManageLeftAndRightMovement(); if (this.CurrentPhase != Phase.None) { var position = this.gameObject.transform.position; position.x += this.InputDirection * this.Speed * this.ADSREnvelope() * Time.deltaTime; this.gameObject.transform.position = position; } if (Input.GetButtonDown("W") && IsGrounded() /*&& !_GrapplingHook.GetConnectionIsActive()*/) { if (rigidBody != null) { rigidBody.velocity = new Vector2(rigidBody.velocity.x, 6.0f); } } // Retract rope / climb the rope. if (Input.GetButton("W") && _GrapplingHook.GetConnectionIsActive()) { _GrapplingHook.ChangeJointDistance(-this.RopeLengthChangeAmount); } // Retract rope / climb the rope. if (Input.GetButton("S") && _GrapplingHook.GetConnectionIsActive()) { if (_GrapplingHook.GetJointDistance() + this.RopeLengthChangeAmount <= _GrapplingHook.GetInitialRopeLength()) { _GrapplingHook.ChangeJointDistance(this.RopeLengthChangeAmount); } } }
// Update is called once per frame void Update() { // var body = this.gameObject.GetComponent<Rigidbody2D>(); // body.bodyType = RigidbodyType2D. // Quaternion desiredRotation = Quaternion.Euler(0, 0, rotationAngle); Quaternion desiredRotation = Quaternion.Euler(0, 0, rotationAngle); //if (this.gameObject.transform.rotation.eulerAngles.y > desiredRotation.eulerAngles.y) // { // Debug.Log("Lerping back to desired rotation"); // this.gameObject.transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotation, smoothTime); // } /* Quaternion desiredRotation = Quaternion.Euler(0, 0, rotationAngle); * this.gameObject.transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotation, smoothTime); * if (this.gameObject.transform.rotation > desiredRotation) * { * this.gameObject.transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotation, smoothTime); * }*/ // Quaternion desiredRotation = Quaternion.Euler(0, 0, rotationAngle); // this.gameObject.transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotation, smoothTime); // if this.gameObject.transform.rotation = Quaternion.Euler // this.gameObject.transform.rotation = Quaternion.identity; var rigidBody = gameObject.GetComponent <Rigidbody2D>(); this.ManageLeftAndRightMovement(); // If we are grappling if (_GrapplingHook.GetConnectionIsActive()) { animator.SetBool("IsJumping", false); animator.SetBool("IsHoldingRope", true); animator.SetFloat("Speed", 0.0f); animator.enabled = false; } else { animator.gameObject.transform.parent.transform.rotation = Quaternion.identity; animator.enabled = true; animator.SetBool("IsHoldingRope", false); animator.SetFloat("Speed", Math.Abs(Input.GetAxisRaw("Horizontal"))); } if (this.CurrentPhase != Phase.None) { var position = this.gameObject.transform.position; position.x += this.InputDirection * this.Speed * this.ADSREnvelope() * Time.deltaTime; this.gameObject.transform.position = position; } if (Input.GetButton("W") && _GrapplingHook.GetConnectionIsActive()) { animator.SetBool("IsJumping", false); } else if (Input.GetButtonDown("W")) { animator.SetBool("IsJumping", true); } if (Input.GetButtonDown("W") && IsGrounded() /*&& !_GrapplingHook.GetConnectionIsActive()*/) { if (rigidBody != null) { rigidBody.velocity = new Vector2(rigidBody.velocity.x, 6.0f); } } // Retract rope / climb the rope. if (Input.GetButton("W") && _GrapplingHook.GetConnectionIsActive()) { _GrapplingHook.ChangeJointDistance(-this.RopeLengthChangeAmount); } // Retract rope / climb the rope. if (Input.GetButton("S") && _GrapplingHook.GetConnectionIsActive()) { if (_GrapplingHook.GetJointDistance() + this.RopeLengthChangeAmount <= _GrapplingHook.GetInitialRopeLength()) { _GrapplingHook.ChangeJointDistance(this.RopeLengthChangeAmount); } } }