Making one object follow another

I am creating a NPC and I divide it to upper part and lower part. How can I make the upper part follow the lower part without using global and through scene layer to access the x and y? Thanks.

Spidey

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If you unlock an actor, you can then access another actor's self attributes (e.g. self.position.X) through the Current Scene sub-menu. You would constrain the upper actor's self.position.X to the lower actor's self.position.X and constrain the upper actor's self.position.Y to the lower actor's self.position.Y + some offset value.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • spidey906spidey906 Member Posts: 52
    Thank you for your reply. I am wondering can I do it without using current scene sub-menu? Can I store the x and y values in table for the lower part , then constrain the x and y values for the upper part from the same table? Is it good for processing? Many Thanks.
  • CORE GameCORE Game Member, PRO Posts: 280
    Sorry to answer your question with another question,, but I also would like to know why you don't want to use global attributes ?

  • spidey906spidey906 Member Posts: 52
    Thanks for your reply. I only want to use one variable to represent all the enemies. It looks like I need to use multiple global variables to store the x and y. Thanks.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You can unlock the actor and access the scene sub-menu to constrain to the actor's self attributes, or you can use a table to store the actors' positions and then constrain to the table values with a timer set to every 0 seconds, or you can constrain game attributes to the actor's position and then constrain the second actor to the game attributes. So you have three choices. I'm not really sure why you're avoiding game attributes either but if you have a good reason then try one of the other options.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.