How do i transform an object vectorially. As an example i want an cube to go 1 m forward then i write
cube.transform.position = cube.transform.position + new vector3(1,0,0);
but what do i write if the cube has rotatet around one or multiple axes and i still want it to go forward on his x-axes? i am thankfull for any help also i wanna mention that i cant use anything parent-child realated because im using prefabs.
// Move the object forward along its z axis 1 unit/second.
transform.Translate(Vector3.forward * Time.deltaTime);
usually the z axis is forward. if you wanted to move along the x axis you would say Vector3.right. you can still use parenting after spawning a prefab if that helps. you would just say someting like this
var prefab:GameObject;
var theparent:GameObject;
var ob:GameObject;
ob=Instantiate(prefab,theparent.transform.position, theparent.transform.rotation);
ob.transform.parent=theparent.transform;