- Home /
How to move child objects perpendicular to parent object's rotation?
Hey,
I have been stuck on this problem for a week now and would love if someone could help me out!
I have 3 planes(see image below). Plane A is a parent of Plane B and Plane C. All three planes rotate together.
My problem is when the user clicks on Plane A; Plane B and Plane C should stop rotating, separate from Plane A and move perpendicularly to Plane A's current rotation. Planes B and C should fire in opposite directions to each other..
Any ideas on how to accomplish this using JavaScript? It has been driving me crazy!
Thanks!
Does 'A' continue to rotate after 'B' and 'C' are launched?
How are you planning to move 'B' and 'C'...Rigdibody? CharacterController? Direct movement of the transform?
What defines the destination for the movement of 'B' and 'C'?
Are 'B' and 'C' children of 'A'? And if so, do they remain children after they are launched?
Are you making these in the Scene View or creating them at runtime? I would be curious to know what your parenting looks like in the Hierarchy pane. Supposing that they were child objects, and had their pivot points in the right place, it should work.
Hey John,
Thanks for replying..
I am making these in the Scene view. Plane A rotates from the start. B and C rotate with it. As soon as the user clicks on Plane A, B and C need to fire(like bullets) in opposite directions to A's current rotation.
Yeah, I think more information on how you're moving these things is in order, if we're to help you. Depending on how you do it, it may be as simple as moving in the direction of A.transform.up or something, but without knowing how you move/rotate the objects it's hard to say.
Hey thanks for replying.. Plane A's mesh will be disabled once clicked. B and C are bullets. They have rigidbodies and I assume I will addforce to move them?
Plane 'A' has a simple rotation script attached to it to make it rotate. Plane 'B' and 'C' rotate with it automatically because they are its children.
Planes 'B' and 'C' are children of 'A' but I am unsure if they should remain children once Plane A is clicked.
$$anonymous$$y goal is to fire 'B' and 'C' in opposite directions to 'A'
Answer by JohnRossitter · Mar 17, 2014 at 07:28 PM
I would detach B & C from A first before disabling A.
Answer by koray1396 · Mar 17, 2014 at 07:48 PM
well, someone brighter than me will probably advise something else. but this would be my way if I understood right;
On mouse down, you can stop rotation and store the eulerAngles of A. Then, C.transform.localPosition.x should move away by somevalue sin(z rotation of A) deltaTime, and local y position would move by somevalue cos(z rotation of A) deltaTime.
Likewise, the movement of B would be the opposite.
I hope this would be useful for you.
Your answer
Follow this Question
Related Questions
Best way to move a Rigidbody2D from point A to point B (Mouse Position) 3 Answers
Different between transform.Translate() and Vector3.MoveTowards? 1 Answer
move enemy to random transform array 2 Answers
Moving an object towards a clicked object 1 Answer
How I can Converting a Direction Vector to Quaternion rotation? 1 Answer