I try find some solution about rotate and calculate position from euler angle. Now, I have a planet, And I want to add gameobject on the planet's surface when I clicked mouse. I doing something like that... The object is on the planet,but they all cluster a small range, and they rotate isn't correct.... This is my code with maincamera... can someone help me? Code (CSharp): using UnityEngine; using System.Collections; using System.Collections.Generic; public class addObjectonPlanet : MonoBehaviour { public GameObject parentObj; public GameObject[] gameObj; int tag; Vector3 mEuler; Vector3 targetPos; public float radius = 3; int angleX, angleY, angleZ; // Use this for initialization void Start (){ } // Update is called once per frame void Update () { if (Input.GetButtonDown ("Fire1")) { angleX = Random.Range (0, 360); angleY = Random.Range (0, 360); angleZ = Random.Range (0, 360); mEuler = new Vector3 (angleX, angleY, angleZ); targetPos = parentObj.transform.position + mEuler.normalized * radius; tag = Random.Range (0, 3); GameObject childObj = Instantiate (gameObj [tag], targetPos, Quaternion.Euler (mEuler)) as GameObject; childObj.transform.parent = parentObj.transform; } } } I just want to add object on the planet, Do not need to walk on the planet.
yes, that can get the position on the surface, but how can I rotate the object at correct direction? just bottom on surface.