Hi, I am trying to access the transform.position of the first child of the parent. The heierachy is as follows:
Parent
–Camera1 (First Person Camera)
–Camera2 (Third Person Camera)
–Bip01
In a script attached to the parent, we have:
public class Projectiles : MonoBehaviour {
public GameObject prefab;
private void Start() {
GameObject FindFPC = GameObject.Find("Camera1");
Debug.Log("FPC Position is: " + FindFPC.transform.position);
}
}
The parent is at the vector3 position: 0,0,0 The camera is at the vector3 position: 0, 10, 0
and for some reason the debug statement is showing 0,0,0 as the position of the FPC varaible.
Basically, I would just like to always instantiate projectiles forward based on the position and rotation of the FPC (first person camera)..So i the same script:
private void InstProjectiles() {
GameObject go = (GameObject) Instantiate(prefab, FindFPC.transform.position, FindFPC.transform.rotation);
go.rigidbody.velocity = go.transform.TransformDirection(Vector3.forward * 100);
}
but it is a little inconsistant, even when I don't move the player. Some of the projectiles are lower the the first..
Has anyone had this problem before?