A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Separate names with a comma.
Discussion in 'Navigation' started by BearSheriff, Jul 11, 2015.
Hey is there a way that I can have 5 objects surround a player and form a pentagon shape?
I think you're referring to objects following the player. If so then why not make them child objects of the player?
well, you know that a pentagram is made up of 5 points around a circle at 72 degrees.
use that knowledge + trig to calculate the x/z positions.
public class Test : MonoBehaviour
public GameObject target;
public GameObject cloneFrom;
public int amount;
public float radius;
Surround (target, cloneFrom, amount, radius);
// this function replicate the object surrounding the target
public void Surround(GameObject target, GameObject prefab, int amount, float radius)
float angle = 360f / amount;
for (int i = 0; i < amount; i++)
GameObject go = Instantiate (prefab) as GameObject;
go.transform.Rotate (Vector3.up, angle*i);
go.transform.position = target.transform.position - (go.transform.forward * radius);
// OR go.GetComponent<NavMeshAgent>().Warp(target.transform.position-(go.transform.forward*radius));