How do I make an object match position?

Get help using Construct 2

Post » Sun Sep 14, 2014 8:49 pm

Not a very clear title...

I have an object that I want to move using the arrow keys. Up down left right.

Now, I also want to have a copy of the exact same object copy its movement exactly, but its Y position at a +200 offset.

I've set up a boolean which separates them, so the arrow keys only effect the correct one, but how do I add in some code that gets an object to follow itself, but with a different boolean?

I could do it easily with a different object, but I'm trying to cut down on my use of sprites.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Sep 14, 2014 9:01 pm

Pin at offset?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Sep 14, 2014 9:12 pm

Hmm, I guess that could work. I'd need to have the object spawn itself, offset it's Y position, change the boolean, then pin.

Nice, this could be a winner!

This the only way to do it? Wish I could add extra parameters to these things so I can more easily reference them. Say for example I only want the object to follow on the x access, not both.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Sep 14, 2014 9:29 pm

Nope, can't get pinning to work. It just tries to pin itself to itself, rather than the original. You can only choose the object from a list, rather than code it in and add a UID to the end :(
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Sep 14, 2014 9:42 pm

Choose by instance 0, and 1. But when you Pin, it will 'follow 'on both axes'. Otherwise you need to do it yourself, every tick. That would be very simple.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Sep 14, 2014 10:08 pm

I'm afraid I do not follow. If I have a choose by UID 1 (which is the copy) I will then need to tell it which one to pin to... but when I add a choose by UID 0 (The original) I can't separate this, as the two will read "Choose by 0 AND Choose by 1". I've never needed to do this, so never learned this part I'm embarrassed to say!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Sep 14, 2014 10:11 pm

No that's fine, Use IID not UID. i.e. pick by Nth

Edit: how much are you going to save by using the same object type? Maybe just use different objects and save a lot of work.

Anyway I've attached something that might help.
You do not have the required permissions to view the files attached to this post.
Last edited by codah on Sun Sep 14, 2014 10:36 pm, edited 1 time in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Sep 14, 2014 10:29 pm

Image

I've also tried doing it using the expressions within the Parameters for X, but not having any luck with that either.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Sep 14, 2014 10:37 pm

AnD4D wrote:Image

I've also tried doing it using the expressions within the Parameters for X, but not having any luck with that either.


Sorry if I was a bit cryptic. Anyway see above ^^ Hope it helps.

Edit: I had some errors and uploaded a new capx. Sorry for multiple uploads.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Sep 14, 2014 11:07 pm

Thanks a lot! I appreciate the help, but I do not believe this method will work.

My game has 4 ships that I need to do this with, and all are already part of a family. I have tried to alter your code to allow a second sprite to be linked in via the same family, but it does not work.

I will go with your initial advice, and just use separate objects. I was trying to avoid this, as my debugger is slowly turning into a nightmare, filled with objects. Sadly, groups do not transition over, so I need to scroll through dozens of objects just to find the one I'm looking for!

I greatly appreciate your help though!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests