Jump to content
  • Advertisement
Sign in to follow this  
FirstStep

Positioning objects relatively

This topic is 841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Say I have  a parent object and I want to position its child base on where the parent go something like this

 

relative_2.jpg

 

Usually i position objects base on screen origin.

 

relative_1.jpg

 

 

Is there a way to position objects or how to position objects base on the parents origin and not screen origin?

Share this post


Link to post
Share on other sites
Advertisement

Just use the parent origin?

 

child.x = parent.x + offset;

child.y = parent.y + offset;

What is the offset?

is it the origin from the parents origin to childs origin? 

Share this post


Link to post
Share on other sites

 

Just use the parent origin?

 

child.x = parent.x + offset;

child.y = parent.y + offset;

What is the offset?

is it the origin from the parents origin to childs origin? 

 

 

The offset is the number you want to move your child based on the parent.

 

So if:

parent.x = 25;

offset = 5;

 

AND

child.x = parent.x + offset;

 

THEN

child.x = 30;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!