- Home /
Question by
skate4life13010 · Oct 29, 2014 at 05:09 AM ·
gameobjectvector3coordinate
Find coordinate location of game objects in scene?
I have a player who moves by transform by 1.0 every step. Every movement I make leaves a clone of a cube behind each step leaving a trail of cubes. I need to find the location(in coordinates) of every cube that was instantiated. Either print the location as I move or at the end when I press a key
Comment
Best Answer
Answer by AlwaysSunny · Oct 29, 2014 at 05:04 AM
Best way is to keep a list of the objects as they're created, and refer to the list as needed.
using System.Collections.Generic;
List<Transform> cubes;
cubes = new List<Transform>();
cubes.Add( myCube.transform );
foreach (Transform cube in cubes) {
Debug.Log(cube.position);
}