1
\$\begingroup\$

enter image description here

So, I have X and Y game objects. I have a vector Z = X - Y which is indicated by the green line.

Also, I have a Parent game object and it has a Child game object. How do I move the parent such that the child game object is at the Point Y

I tried,

                  Z -= new Vector3(child.localPosition.x, 0, child.localPosition.z);
                  Parent.transform.position = Z

which is not working as expected. Thank you!

\$\endgroup\$
1
  • \$\begingroup\$ What does Z have to do with all of this? Just add Y - C.transform.position to the parent's position \$\endgroup\$
    – Bálint
    Commented Aug 2, 2019 at 18:04

1 Answer 1

2
\$\begingroup\$

Did you try something like this?

childToTarget = targetPosition - child.position;
childToTarget.y = 0;

parent.position+= childToTarget;
\$\endgroup\$
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.