make groups of objects move together [SOLVED]

Get help using Construct 2

Post » Sun Dec 08, 2013 2:37 am

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!
Calebpart12studios2013-12-08 03:31:15
B
59
S
9
G
1
Posts: 939
Reputation: 6,545

Post » Sun Dec 08, 2013 2:50 am

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.
MadFactory2013-12-08 02:54:13
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Sun Dec 08, 2013 2:54 am

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.
B
59
S
9
G
1
Posts: 939
Reputation: 6,545

Post » Sun Dec 08, 2013 3:03 am

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
B
59
S
9
G
1
Posts: 939
Reputation: 6,545

Post » Sun Dec 08, 2013 3:30 am

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
B
59
S
9
G
1
Posts: 939
Reputation: 6,545

Post » Sun Dec 08, 2013 3:33 am

Really sounds like the Pin behaviour.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sun Dec 08, 2013 4:20 am

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
B
59
S
9
G
1
Posts: 939
Reputation: 6,545


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, nahima and 12 guests