i've been searching but got no outcome of it..
I want to make a transform to an object, but the transformation script is on his child. so, if i use
myTransform = transform.parent;
on the child, it does a relative-to-parent transform, but i want it to move the parent (relative to global).
*Edited lines where the transformation happens
//rotation myTransform.Rotate(0, (int)_turn * Time.deltaTime *rotationSpeed,0);
moveDirection = new Vector3(0,0,(int)_forward);
//back-forward moveDirection = myTransform.TransformDirection(moveDirection).normalized;
moveDirection *= swimSpeed;
A little more info would help like are you using a rigidbody on the parent? If so then just access the rigidbody of the parent and apply movement to that game object. I don't see any actual movement code above so i'll just give u a simple example You can do this in any script. For example...
This will move the parent object relative to global like you wanted. Hope this helps
answered Jul 20 '12 at 08:30 PM