Picking the correct object

This forum is currently in read-only mode.
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • 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.

    <img src="http://dl.dropbox.com/u/54897686/Events1.jpg" border="0" />

    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?

  • 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'

  • 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.

    dl.dropbox.com/u/54897686/SonicConstruct.rar

  • I second the suggestion about using For Each Object instead of always

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

    dl.dropbox.com/u/919275/SonicConstructMultiReDo.cap

  • 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.

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