- Home /
Moving objects based off an object in a sphere.
Ok ... I have a ship that is moving through space ... When it reached the edge it is relocated to the _ Like going out one side of the screen and reappearing on the other side ... My problem is how to call all the asteroids to move to the other side in respect to where they are from the ship ... What would be the call to move the asteroids to there new positions. There are a few way to go about this. But I keep getting lost in how to even call this ...
Answer by tavro · Apr 24, 2020 at 06:49 AM
The best way would probably be to have the asteroids be children of the ship.
You could set the ship as the parent when you instantiate the asteroids:
Instantiate(asteroid, new Vector3(x, y, z), Quaternion.identity, ship.transform);
Answer by DataSmith2112 · Apr 24, 2020 at 07:23 AM
That didn't work and where is the x,y,z coming from. ...
What I mean is that it's not efficient to go through every asteroid and change their transforms and so on. What you probably want to do ins$$anonymous$$d is to have them be children to the ship - that will make them go whereever the ship is. Doesnt matter when you do it - you could even do it in the inspector. I was assu$$anonymous$$g you were instantiating them, because I guess you have quite a few asteroids...
Your answer
![](https://koobas.hobune.stream/wayback/20220612232325im_/https://answers.unity.com/themes/thub/images/avi.jpg)