GameMaker [Solved] One Way platforms sometimes work and sometimes don't

yashamatt

Member
I have basic movement and collision with solids set up, but when I try to set up my one-way platforms I will only be able to interact with whatever one-way platforms that have a lower y-axis than the obj_player when the room is created. If I decrease the spawn y-axis of the obj_player then load the game, all one-way platforms that have a higher y-axis cease to work and behave as if it is not there. Forgive my formating.

In o_game_controller
room start
Code:
if !instance_exists(o_player) 
{
      instance_create_layer(o_spawn.x, o_spawn.y, "Instances", o_player);
}
In o_player Step Event
Code:
// from falling state to idle state

if state == player.falling      
{
      var _underBlock = place_meeting(x, y + 1,o_oneway_up);

      if place_meeting(x, y+1,par_solid) || (place_meeting(x, y + 1, o_oneway_up) && !place_meeting(x, y, o_oneway_up) && _underBlock.bbox_top > bbox_bottom)     
      {
              state = player.idle;        
      }         
}
Code:
// from idle state to falling

if !place_meeting(x, y + 1, par_solid) && !place_meeting(x, y + 1, o_oneway_up)
{
      state = player.falling;   
}
Code:
// Vertical movement
repeat (abs(ySpeed))
{
      var _underBlock = place_meeting(x, y + 1, o_oneway_up);
      if (place_meeting(x, y + sign(ySpeed), o_oneway_up) && ySpeed > 0 
      && !place_meeting(x, y, o_oneway_up) && _underBlock.bbox_top>bbox_bottom)
      {
            ySpeed = 0;
            break;
      }    
      else if (!place_meeting(x, y + sign(ySpeed), par_solid)) 
      {
            y += sign(ySpeed);
      }
      else
      {
            ySpeed = 0;
            break;
      }
}

o_spawn itself has no code.
I don't check for one way platforms at all in my horizontal collisions (just par_solid), but if it is needed for clarity I'll post it, likewise with whatever else might be needed but I don't even know what else could cause this interaction.

I suspect it has something to do with
Code:
 var _underBlock = place_meeting(x, y + 1, o_oneway_up);
only recognizing the target objects with lower y-axis to o_player and none with a higher y-axis, but truly I have no idea why it is working this way.
 
Z

Zenru45

Guest
I'm still trying to figure out your code. This part is throwing me off:

var _underBlock = place_meeting(x, y + 1, o_oneway_up);
if (place_meeting(x, y + sign(ySpeed), o_oneway_up) && ySpeed > 0
&& !place_meeting(x, y, o_oneway_up) && _underBlock.bbox_top>bbox_bottom)

_underBlock should be a true/false or 0 /1 boolean value from place_meeting(), right? '_underBlock.bbox_top' suggests its an object with a collision mask.
 

yashamatt

Member
I'm still trying to figure out your code. This part is throwing me off:

var _underBlock = place_meeting(x, y + 1, o_oneway_up);
if (place_meeting(x, y + sign(ySpeed), o_oneway_up) && ySpeed > 0
&& !place_meeting(x, y, o_oneway_up) && _underBlock.bbox_top>bbox_bottom)

_underBlock should be a true/false or 0 /1 boolean value from place_meeting(), right? '_underBlock.bbox_top' suggests its an object with a collision mask.
I only want the code to take effect when the o_player is one pixel above the semi-solid. the problem is there are multiple ones in the room and for a reason unknown to me only ones that have a lower y-axis to the player at the point when the room starts seem to work. my aim is to try to make semi-solids or one-way platforms like in Mario but I can only get it to work half the time.
 
Z

Zenru45

Guest
Hmm okay... 'only ones that have a lower y-axis to the player at the point when the room starts seem to work' that sounds like the player 'y' position isn't being updated. Try checking how your character falls in terms of y values? Maybe it has something to do with how gravity works? I'll give it some more thought. This is a tricky one.
 
P

Palocles

Guest
Why not use the code Shaun Spaulding uses in his one way platform tutorial?

I’ve used it and it works but i’m having trouble getting the player to be carried by the vertically moving platform.
 

yashamatt

Member
Why not use the code Shaun Spaulding uses in his one way platform tutorial?

I’ve used it and it works but i’m having trouble getting the player to be carried by the vertically moving platform.
is that the one where the character checks if a collision block is solid? I had a look at it a while ago but i have other objects effected by gravity that I want to behave like the player.
in my system i wanna check if the player is 1 pixel above the oneway platform then initiate the code.
 

TheouAegis

Member
I only want the code to take effect when the o_player is one pixel above the semi-solid. the problem is there are multiple ones in the room and for a reason unknown to me only ones that have a lower y-axis to the player at the point when the room starts seem to work. my aim is to try to make semi-solids or one-way platforms like in Mario but I can only get it to work half the time.
Have you changed this
Code:
var _underBlock = place_meeting(x, y + 1, o_oneway_up);
to this yet?
Code:
var _underBlock = instance_place(x, y + 1, o_oneway_up);
 

yashamatt

Member
Have you changed this
Code:
var _underBlock = place_meeting(x, y + 1, o_oneway_up);
to this yet?
Code:
var _underBlock = instance_place(x, y + 1, o_oneway_up);
with an instance_exists check this works perfectly. thanks again TheousAegis
what is the difference between place_meeting and instance_place that makes this work?
 
Top