void Update() { //檢測互動物件需求方向和玩家面相方向是否一致 bool playerFacing = requiredDirect * scPlayer.face < 0 ? false : true; if (canInteract && scPlayer.CanControl() && playerFacing) { RaycastHit2D hit = Physics2D.Raycast(transform.position + new Vector3(0.2f, 0, 0), Vector3.left, 0.4f, playerMask); anim_EHint.SetBool("on", hit.collider != null); } else { anim_EHint.SetBool("on", false); } }
void Update() { float dx = playerTR.position.x - transform.position.x; if (playerSC.CanControl() && Mathf.Abs(playerTR.position.y - transform.position.y) < 2 && Mathf.Abs(dx) < 0.5f * range) { HintOn(true); } else { HintOn(false); } float posX = transform.position.x - dx * distanceRatio; canvasTR.position = new Vector2(posX, canvasTR.position.y); }