Picking the correct object

For questions about using Classic.

Post » Tue Jan 10, 2012 3:09 pm

Hello. I'm working on a custom movement engine that will have multiplayer incorporated into it. I'm having an issue with choosing the right object when needed. Right now there are 2 of the same sprite called "player". Each has a private variable called "player". One has Player = 1, the other has Player = 2. The engine has many sensors which detect wall collisions, slopes, floor and ceiling. I got those to correctly attach to the right "player" object by checking if their "player" variable is = to the player object's variable. I'm having trouble with picking the correct player object to set X and Y speeds to. I have an input object that also wants to be linked through a "player" variable. I can correctly get the input object to link to the player object by checking the player variable but I can't seem to figure out how to single out the player object I want to move. If I move one player object, they both move because the engine is setting the X and Y speeds for both of them. How can I loop through the correct player object to get it to move correctly based on what is controlling it? I plan to have 4 player objects work under the same movement engine but I can't seem to figure out a way to make it choose the right one to move. Can any one of you help me? I would greatly appreciate it.



This is the event that I want to cycle through each character. I want them to all have separate X and Y speeds. Would I have to copy this 4 times or is there a way to loop through this to get it to only correspond to the individual characters?StreakThundrstrm2012-01-10 15:13:44
B
2
S
1
G
1
Posts: 12
Reputation: 624

Post » Tue Jan 10, 2012 5:05 pm

First of all, the default behaviours handle multiple players. So that is an option.

Otherwise, try using a 'for each object' event instead of an 'always'
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Tue Jan 10, 2012 10:14 pm

I'm not interested in the default behaviors. They don't do what I want them to. Here's the cap so someone can take a look. I stripped it of any extra dealings I tried to change in order to get it to work. Its the engine without trying to implement multiplayer. The events to control X and Y speed as well as sensor placing is in the "Motion Management" group in the player code event sheet.

http://dl.dropbox.com/u/54897686/SonicConstruct.rar
B
2
S
1
G
1
Posts: 12
Reputation: 624

Post » Wed Jan 11, 2012 4:11 am

I second the suggestion about using For Each Object instead of always
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Jan 11, 2012 7:09 am

You guys might wanna actually check out the cap before you go making suggestions. It's a pure event-driven system that utilizes quite a few sensors.

For reference, I'm gonna toss up my own version of that cap that's a WIP of trying to implement individual working players, complete with picking. My method for picking may not be entirely sound, however, though it does seem to work on my end.

http://dl.dropbox.com/u/919275/SonicConstructMultiReDo.cap
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Thu Jan 12, 2012 11:54 am

Thanks Lucid and Steven. I did use a "for each" and it seemed to work well but I had to do much more to it than just that. Thank you for pointing me in the right direction.
B
2
S
1
G
1
Posts: 12
Reputation: 624


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests