0
\$\begingroup\$

Hello I have an Object player and inside player, I have an object Boundary which is supposed to follow the player as he moves up or down only? (As the player moves right or left I don't want the boundary object to move. How can I do it?

\$\endgroup\$
3
  • \$\begingroup\$ What do you mean you don't want it to move? then why attach it to the player object? \$\endgroup\$ Jan 8, 2020 at 6:27
  • \$\begingroup\$ I want it to follow the player only vertically. but not horizontally \$\endgroup\$
    – novapack
    Jan 8, 2020 at 7:06
  • 1
    \$\begingroup\$ You need to explain exactly what you are trying to do, if you want to get the best possible assistance. Pictures would help. Your current description is ambiguous. \$\endgroup\$
    – Engineer
    Jan 8, 2020 at 7:48

1 Answer 1

1
\$\begingroup\$

Does it have to be a child object? If not; Create another object. Get a transform reference to it. Update its transform each frame like so;

object.position = new Vector2(transform.position.x, object.position.y);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .