public void NewCover(CoverController _cover) { if (this.rigidBody == null) { this.rigidBody = GetComponent<Rigidbody2D> (); } this.rigidBody.gravityScale = 0; if (this.cover != null) { this.cover.OffCover (); } _cover.OnCover (); this.cover = _cover; this.currentState = State.TRANSITIONING; this.lastPosition = transform.position; // hitCollider.SetActive (true); this.collider.enabled = false; if (!rightCoverSide) { this.target = _cover.PositionOne; } else { this.target = _cover.PositionTwo; } this.movingSpeed = this.target - this.lastPosition; this.movingSpeed.Normalize (); this.movingSpeed *= this.transitionSpeed; rigidBody = GetComponent<Rigidbody2D> (); rigidBody.velocity = Vector2.zero; animator.Play ("idle"); }