public void ReleaseSomething() { if (playerAnimator.GetBool("isHoldWeapon") || playerAnimator.GetBool("isCrouched")) { return; } playerAnimator.SetLayerWeight(playerAnimator.GetLayerIndex("Hand Layer"), 0);//更改手部动画层权重 playerAnimator.SetBool("isPulling", false); playerAnimation.switchHand(false); //上面动画相关 if (pullInterface != null) { pullInterface.BeReleased(); pullInterface = null; } }
public void GrapeSomething() { if (playerAnimator.GetBool("isHoldWeapon") || playerAnimator.GetBool("isCrouched")) { return; } RaycastHit2D hit; if (this.transform.lossyScale.x > 0) { hit = Physics2D.Raycast(transform.position + new Vector3(0, -1), Vector2.right, 9f, interactiveLayerMask);//调整方向 Debug.DrawLine(transform.position + new Vector3(0, -1), new Vector2(transform.position.x + 9f, transform.position.y - 1), Color.green, 1f); } else { hit = Physics2D.Raycast(transform.position + new Vector3(0, -1), Vector2.left, 9f, interactiveLayerMask);//调整方向 Debug.DrawLine(transform.position + new Vector3(0, -1), new Vector2(transform.position.x - 9f, transform.position.y - 1), Color.green, 1f); } if (hit.collider != null) { pullInterface = hit.collider.GetComponent <ICouldBePull>(); if (pullInterface != null) { pullInterface.BeGraped(this.gameObject); playerAnimator.SetLayerWeight(playerAnimator.GetLayerIndex("Hand Layer"), 1);//更改手部动画层权重 playerAnimator.SetBool("isPulling", true); playerAnimation.switchHand(true); //上面动画相关 } else { Debug.Log("此物体无法拖动(可能是未实现ICouldBePull)"); } } }