public void Add(PositionFollow next) { if (!Next) { next.Target = transform; } else { next.Target = Next.transform; } Next = next; }
private void Start() { GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player) { this.player = player.GetComponent <ShipStructure>(); } audioSource = GetComponent <AudioSource>(); collider2d = GetComponent <Collider2D>(); rigidbody2D = GetComponent <Rigidbody2D>(); outline = GetComponent <Outline>(); positionFollow = GetComponent <PositionFollow>(); shipComponent = GetComponent <ShipComponent>(); outline.eraseRenderer = true; offset = Random.Range(0, 100); basePosition = transform.position; mask = GetComponent <SpriteMask>(); renderer = GetComponent <SpriteRenderer>(); if (mask) { mask.alphaCutoff = UnityEngine.Random.Range(maskMin, maskMax); } // floating component is set to execute after last after othe scripts, but before the floating component spawner if (transform.parent) { // Spawned parented to something, so assume try attaching to it! ShipStructure structure = transform.parent.GetComponent <ShipStructure>(); if (structure) { // Attach to that bad boy TryAttachToShip(structure); } } }