void Start() { myRigidbody = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); lastMoveDirection = new Vector2(0f, 0f); vectorUp = new Vector2(0, 1 * scareMoveSpeed); vectorDown = new Vector2(0, -1 * scareMoveSpeed); vectorRight = new Vector2(1 * scareMoveSpeed, 0); vectorLeft = new Vector2(-1 * scareMoveSpeed, 0); state = GuardState.Standing; startPoint = transform.position; spriteR = gameObject.GetComponent <SpriteRenderer>(); sprites = Resources.LoadAll <Sprite>("guard"); ChildCatchPlayer = this.gameObject.transform.GetChild(0).GetComponent <CatchPlayer>(); ChildScareIcon = this.gameObject.transform.GetChild(2).gameObject; ChildCatchIcon = this.gameObject.transform.GetChild(3).gameObject; turnValue = moveSpeed / 100; scareTurnValue = scareMoveSpeed / 80; catchingPlayer = false; }
void Start() { if (directionUp) { directions.Add(up); } if (directionLeft) { directions.Add(left); } if (directionDown) { directions.Add(down); } if (directionRight) { directions.Add(right); } ChildCatchPlayer = this.gameObject.transform.GetChild(0).GetComponent <CatchPlayer>(); ChildCatchIcon = this.gameObject.transform.GetChild(1).gameObject; spriteR = gameObject.GetComponent <SpriteRenderer>(); sprites = Resources.LoadAll <Sprite>("guard"); currentDirectionIndex = getStartDirection(); rotate(directions[currentDirectionIndex]); catchingPlayer = false; }