make groups of objects move together [SOLVED]

0 favourites
  • 7 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • I'd like to have something like a ship that moves around and have independent parts that move with it.

    With GameSalad I would have to make a master object and constrain global variables X and Y and have subsequent attached objects slave to that value, however I'm not sure with C2 because:

    1. if it's even possible to do this approach in the first place. I feel like the use of "every tick" should be avoided at all costs in terms of efficiency.

    2. if there isn't a smarter way to do it with C2.

    Thanks!

    Caleb

  • I'd just give the parts 2 private vars - x_offset and y_offset, then set their positions to the parent ship + those vars every tick (so you can move them around bit). Alternatively you can give the parent ship image points and set the parts to those. You can also try the pin behavior I guess.

    Using 'every tick' like this is not a big deal, and isn't for most things.

    As for the new question..you can have a single object for all the wings and such - just use different animations and variables to set them apart.

  • Hey MadFactory, Ok I'll try that. I was just trying out some stuff.

    I realize now also that I need to add some depth to the question, I would be looking to ideally having multiple common objects move in unison.. for example.. you have a space ship with two sets of wings. I wouldn't want to make 4 unique wing objects if i could instead use 1 wing 4 times.

    The intent is to make the idea of having numerous common objects that share the same basic properties

    With game salad this wasn't possible. I had to make lots of unique objects to attach them all and this got really cumbersome if you wanted to make simple changes because then you had to go in and make the changes by hand for each object.

    It's ok with 1-2 things, but when you get into having dozens of things on the screen it can become very ugly and difficult to manage.

  • I'm thinking through it and my math is kinda weak in this area, but it seems like there must be an expression that i could use that would work like this.. if i reference the X and Y of a master object.. and compare it to the local X and Y of a given object (since it's local each object would listen independently I believe)..

    so it's like yea some kind of offset.. noting initially where an object is in relation to the master object and then from there on.. any subsequent changes of the master position, all other objects would update.. but damn if i know how to pose this to C2.. heh

  • ok well chalk one up for figuring this one out thanks to MadFactory's advice.. now I get it.. understanding that a local variable is truly unique to THAT object on the screen.. thus allowing duplicate objects to behave independently.. very exciting! :)

    Thanks

    Caleb

  • Really sounds like the Pin behaviour.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • oh wow, Pin Behavior is awesome. :) I just researched that and yea that's pretty spot on as well! got it working after a quick read. that's handy and a lot less leg work.

    however i will say it was beneficial for me just to better understand how instance vars work.

    Thanks!

    Caleb

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)