// Færa fylgjanda í átt að leiðtoga (t.d. notað áður en bardagi byrjar við Yonas) public void MoveFollowerBehindLeader() { FollowerTarget target = new FollowerTarget(transform.position, (Direction)animator.GetInteger("Direction")); // Láta fylgjanda vera einni einingu fyrir aftan leiðtoga float offsetX = 0f; float offsetY = 0f; if (target.direction == Direction.Up) { offsetY = -1f; } else if (target.direction == Direction.Down) { offsetY = 1f; } else if (target.direction == Direction.Right) { offsetX = -1f; } else if (target.direction == Direction.Left) { offsetX = 1f; } target.pos.x += offsetX; target.pos.y += offsetY; followerPlayer.MoveTo(target, walkSpeed); }
// Ef leikmaður hefur hreyft sig nóg til að fylgjandi eigi að hreyfa sig er kallað í þetta fall, sem undirbýr hreyfinguna public void MoveTo(FollowerTarget target, float speed) { // Stilla allar þær upplýsingar sem þarf til að færa fylgjanda this.walkSpeed = speed; this.moveStartTime = Time.time; this.startPos = transform.position; this.targetPos = target.pos; this.journeyLength = Vector3.Distance(startPos, targetPos); this.isMoving = true; // Stilla animator-eigindi animator.SetInteger("Direction", (int)target.direction); animator.SetBool("Walking", true); }