# Star-Shaped Movement
*Distant.relative*: [[IBU/NARRATIVE/Characters/Dancing Stars|Dancing Stars]]
This code creates an interactive star-shaped path and places an object at one of its vertices.
On buttons, the object can complete one full circuit around the star or move continuously in a loop.
![[DESIGNS/TOYS/StarUFO.gif]]
## Code
```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StarSceneContr : MonoBehaviour
{
public GameObject star;
public GameObject uFO;
private GameObject uFOclone;
// Star-rays positions
public List<Transform> starPositions;
private int currentIndex = 0;
private float objectSpeed = 3f;
// Flags
private bool movesInCircle = false;
private bool movesInLoop = false;
public void OnButtonInst_Star()
{
star.SetActive(true);
}
public void OnButtonInst_UFO()
{
uFOclone = Instantiate(uFO, starPositions[0].position, Quaternion.Euler(0, 0, 0));
}
public void OnButton_Circle()
{
currentIndex = 0;
movesInLoop = false;
movesInCircle = true;
}
public void OnButton_Loop()
{
currentIndex = 0;
movesInCircle = false;
movesInLoop = true;
}
private void MoveObject()
{
if (movesInCircle || movesInLoop)
{
// Movement
Transform target = starPositions[currentIndex];
uFOclone.transform.position = Vector3.MoveTowards(uFOclone.transform.position, target.position, objectSpeed * Time.deltaTime);
// Change target
if (uFOclone.transform.position == target.position)
{
currentIndex++;
// Stop or loop
if (currentIndex >= starPositions.Count)
{
if (movesInLoop)
currentIndex = 0;
else
movesInCircle = false;
}
}
}
}
private void Update()
{
MoveObject();
}
}
```