One way platforms in 2 player game

fatsomania36

  • Posts: 15
So I'm wondering how to do one way platforms on a game with 2 players. I just can't think of a way to make it work. Using the way where you just switch the animation if the player is above the platform to solid makes it so the second player cannot pass through it, because it becomes a solid block. Does anyone know of a way to do it if 2 players are on the screen at the same time?

squeeb

  • Posts: 1609
Two platforms? That are over one another... different Collison groups for the platforms.. One collides with player 1.. and the other collides with player 2... that's what ibwould try... I haven't yet though :p

ceosol

  • *
  • Posts: 2275
I did it by having two actors platforms on top of each other. One reacts to player 1 and the other reacts to player 2. The multiple collision groups would work also, but you would need 4 states
Both pass through with nothing on top
P1 pass through and P2 solid
P2 pass through and P1 solid
Both solid

Luyren

  • *
  • Posts: 2239
I did it with a sensor platform, and a behavior on the player actor. If it detects a collision with the sensor of a specific actor group, when the actor has a positive Y speed, it will set the attributes for the actor to think it's on ground, and lock it's Y position.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

fatsomania36

  • Posts: 15
I did it with a sensor platform, and a behavior on the player actor. If it detects a collision with the sensor of a specific actor group, when the actor has a positive Y speed, it will set the attributes for the actor to think it's on ground, and lock it's Y position.
I like your idea.  How exactly would I lock my Y position and make the actor think it's standing on something solid?

Luyren

  • *
  • Posts: 2239
I attached a screen shot of my behavior, and highlighted the relevant parts. In a nutshell, this behaviors decides when the actor is on ground, whether on a sensor one-way platform, or solid ground. All other behaviors use the attributes from this behavior when they need to know if the actor is on ground. With this, I only have to configure the correct collision group in this behavior, and set the platforms to the same collision group.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

fatsomania36

  • Posts: 15
Thanks for showing me your behavior, but I really don't fully understand it.  Is there a simpler way to do it?  Because if not, I don't know if it's worth the trouble because I have to get my game done very soon and there are other more important things to focus on. Would it be possible to send me your behavior, or is it too intertwined in your game for it to be readily usable?

« Last Edit: May 17, 2017, 03:54:18 pm by fatsomania36 »

Luyren

  • *
  • Posts: 2239
In your jump behavior, use these blocks to get the attributes from your ground detection behavior that determine when the actor is on ground. Then, allow the jump when the actor is on ground.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

fatsomania36

  • Posts: 15
I don't have a behavior just for ground detection, but can't I use the ground detection from the jumping behavior?  The attachment shows what I tried.  Is there a way to get the actor value to work?

Luyren

  • *
  • Posts: 2239
Yes, you can use the ground detection from your jump behavior. What matters is to set the same values/attributes for ground detection when on solid ground when you detect the sensor collision. As long as your jump behavior checks for that value to allow the jump, then it should work.

One thing I forgot to mention: you should make some exceptions on the sensor collision code for when your actor is jumping up. Reason is, if you try to jump up, the actor won't be able to because of the "lock" on its Y position. You could do this by not locking the position when your jump key is down, for example.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter