I have 1 prefab and create 17 pieces on the stage. The coordinates of each prefab are different. But how can I make one animation so that when I click on an object it moves to a given point. Point one for all prefabs.
Source: https://ru.stackoverflow.com/questions/557542/
All Articles
updateyou will simply loop through this list / array by changing its coordinates - Alexey Shimanskyforeach (var obj : myObjects) { obj.transform.position = Vector3.MoveTowards(obj.transform.position, target.position, step * Time.deltaTime); }foreach (var obj : myObjects) { obj.transform.position = Vector3.MoveTowards(obj.transform.position, target.position, step * Time.deltaTime); }that is, each object will change its position according to the condition - Alexey ShimanskyMove()method for a script hung on a prifab. Anyway, most likely, in the initializer script (which makes it clear that objects need to start moving) will need to hold an array with references to objects. So at the right time just go through the array and sayobj.Move()- Alexey Shimansky