x


Parent transform

Hey,

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).

any thoughts?

*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;

more ▼

asked Jul 20 '12 at 02:41 PM

Meldow gravatar image

Meldow
5 3 4 5

I'm not sure what you're asking without more information. Changing the transform for a child occurs as it normally would. Changing the transform for a parent makes all children to the parent transform equally.

Jul 20 '12 at 08:59 PM Doireth
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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...

var myTransform = transform.parent;

myTransform.Translate(Vector3.forward * Time.deltaTime, Space.World); // you would obviously replace this with your actual movement code

This will move the parent object relative to global like you wanted. Hope this helps

more ▼

answered Jul 20 '12 at 08:30 PM

stingman gravatar image

stingman
562 24 29 33

(comments are locked)
10|3000 characters needed characters left

aaaaaaand it worked

love you <3

more ▼

answered Jul 23 '12 at 07:15 PM

Meldow gravatar image

Meldow
5 3 4 5

(comments are locked)
10|3000 characters needed characters left

ohh, Space.World, didnt know that!

Will try that monday and report back! thx

more ▼

answered Jul 20 '12 at 09:30 PM

Meldow gravatar image

Meldow
5 3 4 5

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1278
x422
x410
x122
x83

asked: Jul 20 '12 at 02:41 PM

Seen: 1106 times

Last Updated: Jul 23 '12 at 07:15 PM