private void changeViewingDirection(KeyCode keyCode) { if (keyCode == moveRight) { this.viewingDirection = ViewingDirectionEnum.RIGHT; spriteRenderer.flipX = true; } else { this.viewingDirection = ViewingDirectionEnum.LEFT; spriteRenderer.flipX = false; } }
private void flipViewingDirection() { float facingX = enemyTransform.localScale.x; facingX *= -1f; enemySpriteRendere.flipX = !enemySpriteRendere.flipX; if (viewingDirection == ViewingDirectionEnum.LEFT) { this.viewingDirection = ViewingDirectionEnum.RIGHT; } else { this.viewingDirection = ViewingDirectionEnum.LEFT; } }
bool checkDirection(ViewingDirectionEnum direction) { if (direction == ViewingDirectionEnum.LEFT) { RaycastHit2D currenthit = Physics2D.Linecast(negativeStartCast, negativeEndCast); if (currenthit.collider != null && currenthit.collider.tag == "Player") { return(true); } } else if (direction == ViewingDirectionEnum.RIGHT) { RaycastHit2D currenthit = Physics2D.Linecast(positveStartCast, positveEndCast); if (currenthit.collider != null && currenthit.collider.tag == "Player") { return(true); } } return(false); }