I need to create an animated object (with iTween) which must move with the First Person Controller in front of the camera.
I instantiate it and starts to move according with the iTween parameters I gave it but when it’s instantiated my object stays in the initial creation position and can rotate as I do with my mouse with my camera but can’t move “with me” as I do when I press the “W”, “A” “D” or “S” keys for movement within the First Person Controller builtin.
I attatched my script for instancing my animated object to a EmptyGameObject already attatched to the Main Camera component of my First Person Controller…So…I supposed that my new instantiated object would heritage not only the rotation movement of my eyes/look, my translation movement too.
The final effect is that I instantiate the object, and the object doesn’t move but I can rotate it as I rotate my look…
What is happenning?.
Thank you very much.
Maybe the problem is that I've got to instantiate taking care of placing through the hierarchy tree: parent (First Person Controller) child of the parent (Main Camera) and finally my instantiated prefab...
Right now I instantiate my prefab and plays its animation and stays in the instancing position but it doesn't follow in front of me meanwhile I'm moving. How can I give to it my movement and rotation when I change the direction of my look?.
var mensaje:GameObject;
var posicion_mensaje: Transform;
private var activate_blue:boolean=false;
function Update()
{
if (Contador_global.activate_blue==true)
{
print("bien");
var go=Instantiate(mensaje, transform.position, transform.rotation);
//go.velocity=transform.TransformDirection (Vector3.forward * 10);
Contador_global.activate_blue=false;
Destroy(go,2);
}
else
{
print("mal");
}
}
What should I modify in order to get the desired result?. This script is attatched to an EmptyObject child of the Main camera in my First Person Controller which is separated 1m from the camera . I've dragged the GamObject from my prefabs folder and I've dragged as position (posicion_mensaje) of the message (mensaje) the EmptyObject.
I’ve solved partially my problem. Now the animated prefab follows me in front of me, as I desired…But the problem now is that the height in its related position to the camera is not reseted or still remains the last height of the last instance or it’s calculated in a wrong way…
Take a look,only with this line after the instance created:
Maybe the problem is that I've got to instantiate taking care of placing through the hierarchy tree: parent (First Person Controller) child of the parent (Main Camera) and finally my instantiated prefab...
– jorgonRight now I instantiate my prefab and plays its animation and stays in the instancing position but it doesn't follow in front of me meanwhile I'm moving. How can I give to it my movement and rotation when I change the direction of my look?.
– jorgon