- Home /
Distance to WorldPos
Hi, i am quite new here. I want to make some objects and the camera is in the center. These objects all should be in the same distance form the camera. Eg earth as then center, and 5 moons in the orbit. And all of these moons should have the same distance to earth.
I have no idea how to do it. Anyone has an idea?
I solved it. I created a class mitemclass with 2 rotations in it (xp und yp). Then i rotate the Camera with the 2 angles and after that, I instantiate an object with the distance zpos. It works.
foreach(mitemclass item in mItemarr) {
Camera.main.transform.eulerAngles = new Vector3(item.xp,item.yp,0);
Vector3 bd = Camera.main.transform.TransformPoint(0,0,zpos);
go = (GameObject)Instantiate(mItem,bd,transform.rotation);
go.transform.parent = transform;
}
Answer by mike1602 · Jun 24, 2010 at 10:22 AM
I solved it. I created a class mitemclass with 2 rotations in it (xp und yp). Then i rotate the Camera with the 2 angles and after that, I instantiate an object with the distance zpos. It works.
Answer by Wolfram · Aug 19, 2010 at 02:15 PM
There's no need to modify your Camera if you don't want to. This should work:
foreach(mitemclass item in mItemarr)
{
go = (GameObject)Instantiate(mItem,transform.position+new Vector3(0,0,zpos),transform.rotation);
go.transform.parent = transform;
go.transform.Rotate(item.xp,item.yp,0);
}
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Getting the world position of mesh vertices? 2 Answers
Snap to starting position? 3 Answers
Camera shake 11 Answers
Move to random position based off user's input of terrain size? 2 Answers