Legacy GM convayor belt

phillipPbor

Member
for platformer fans, have you guy ever made a platform conveyor belt obj before?
because I saw megaman rid'in it. why don't shaun or everyone make an conveyor belt for there own games?

or better yet... how do you make them?

I mean it is easy, but not after going the left way on the conveyor belt that drags the player the other way. it made a player stop when place meeting are on both of them in between.
sprite93_0.png

don't you get it?

ill code it out for you all

Code:
set variable image_speed to 0.4
Step Event:

if at relative position (0,-2) there is object obj_player
      for all obj_player: jump relative to position (1,0)
else
      for all obj_player: jump relative to position (0,0)
 

Nux

GameMaker Staff
GameMaker Dev.
I honestly can't tell if you're asking for help or showcasing an idea.

i don't get it?

so, ill code it out for you

Code:
if isTutorial then
    output message:
        What about if you'd like to have momentum conserved like in super mario?
        Jumping to a relative position won't help you do that! 8^)
        There should be a variable which builds up over time which is like an 'extra speed' so you player can shift into MAXIMUM OVERDRIVE

else
    output message:
        // TODO: insert code which handles problem here
 

TheouAegis

Member
Code:
////Create Event////
scroll_timer = 0;
scroll_speed = 1/4;
scroll_direct = -1;
Code:
////Step Event////
scroll_timer+=scroll_speed;
while scroll_timer > 1
{
    scroll_timer -= 1;
    with instance_place(x,y-1,obj_player) x += other.scroll_direct;
}
 
Last edited:

TheouAegis

Member
Code:
if isTutorial then
    output message:
        What about if you'd like to have momentum conserved like in super mario?
        Jumping to a relative position won't help you do that! 8^)
        There should be a variable which builds up over time which is like an 'extra speed' so you player can shift into MAXIMUM OVERDRIVE
Did the conveyor belts actually help Mario reach terminal horizontal velocity?
 

NightFrost

Member
The way I have conveyor belts move player is to set up variables on player object for the effect. Call them External_x and External_y or whatever, and the conveyor sets values on them. Then the player step event adds them to hspd and vspd (or whatever you call them) and zeroes them. This way, the conveyor will not push the player inside objects if any are in the way, and doesn't need to do collision checking for the player because the player object will do it as matter of course.
 

phillipPbor

Member
Whoops, forgot the other. I fixed the code above.
okay here is a drill... I want to do the experiment game...
and to do that I just need support.
look at this conveyor belt sprite.
(
)
tell me... what do you all see in this pixelated sprite?
anything different?
 

TheouAegis

Member
Different from what? I see a base with no stereoscopy and a belt rotating right with stereoscopy.

If the belt is going one way and the player is going another way and you don't want the player to be able to walk while the belt is going the opposite direction:

scroll_direction = 1 //since the sprite you posted is going right for now
...
with instance_place(x,y-2,obj_player)
if sign(hspd) != other.scroll_direction hspd = 0;
else hspd *= 2;

Like Nux said, your posts are a bit confusing sometimes. There are various ways to handle conveyor belts. Nux pointed out one type, I pointed out two others.
 

phillipPbor

Member
Different from what? I see a base with no stereoscopy and a belt rotating right with stereoscopy.

If the belt is going one way and the player is going another way and you don't want the player to be able to walk while the belt is going the opposite direction:

scroll_direction = 1 //since the sprite you posted is going right for now
...
with instance_place(x,y-2,obj_player)
if sign(hspd) != other.scroll_direction hspd = 0;
else hspd *= 2;

Like Nux said, your posts are a bit confusing sometimes. There are various ways to handle conveyor belts. Nux pointed out one type, I pointed out two others.
well you did learned the color concepts...
red that gose to the left
cyan that gose to the right
and when the colors switched between red and cyan, the belts change direction.
 

TheouAegis

Member
Okay. So when you change it from red to blue or vice-versa, multiply scroll_direct*=-1 to reverse the direction of the conveyor.

_r = 0;
scroll_direct = 1;

_r = !_r;
scroll_direct *= -0

So then the question remains, how do you want the conveyor to explicitly affect the player's movement when the player is on it?
 

TheouAegis

Member
Code:
//create event//
_R = 0;
_direct = 1;
_spd = 1.5;    //change this to m/change this to make the player move faster
_timer = 0;

Code:
//step event//
_timer += _spd;
while _timer >= 1
{
    --_timer;
    with instance_place(x,y-2,obj_player) x += other._direct;
}

When you change the direction of the conveyor:
Code:
_R = !_R;
_direct *= -1;
 

phillipPbor

Member
Code:
//create event//
_R = 0;
_direct = 1;
_spd = 1.5;    //change this to m/change this to make the player move faster
_timer = 0;

Code:
//step event//
_timer += _spd;
while _timer >= 1
{
    --_timer;
    with instance_place(x,y-2,obj_player) x += other._direct;
}

When you change the direction of the conveyor:
Code:
_R = !_R;
_direct *= -1;
look closerly
 

phillipPbor

Member
Ok i'm going off to work.

How is the player moving?
the player moving perfect except I cant push through to get the other conveyor belt as I run through left while it runs right.

for full view

(EDIT: oh my god what!? let me fix it but you get what I mean do you?)

(I give up, but you get message)
 
Last edited:

TheouAegis

Member
Remove all code from the conveyors. Does the playerove across the cpnveyor normally as if he was running on normal ground?

(on break, just checked in)
 

TheouAegis

Member
Haha stupid phone.

Does the player move across the conveyor normally as if he was running on normal ground?

Go into the conveyor object, put exit at the start of each code so it doesn't run any code. Load up the game. Try to walk back and forth across the conveyor objects. If the player can walk across them just fine just like he was walking on normal ground, then good (well bad, cuz then I wouldn't know why my code wasn't working). But if the player can't walk across the conveyor belts as normal, then the problem is the player's movement code.
 

phillipPbor

Member
Haha stupid phone.

Does the player move across the conveyor normally as if he was running on normal ground?

Go into the conveyor object, put exit at the start of each code so it doesn't run any code. Load up the game. Try to walk back and forth across the conveyor objects. If the player can walk across them just fine just like he was walking on normal ground, then good (well bad, cuz then I wouldn't know why my code wasn't working). But if the player can't walk across the conveyor belts as normal, then the problem is the player's movement code.
what Is wrong with the movement?
 

phillipPbor

Member
Yeah, I made them both in Kirbyvania and Daemon Detective Gaiden. Anything else you're wondering?
yah... I have... I have this problem. like you see the picture from above. I was wondering... how do you make a better conveyor belt? because the pic you see above you shows the problem accord to me.
 

Nux

GameMaker Staff
GameMaker Dev.
oH I think I get what you mean now!

Don't update the player in the conveyor belt objects, check for a conveyor belt collision in the player object instead

EDIT: pseudo code
Code:
inside player step event:
if there is a collision BELOW the player with obj_conveyorbelt {
    x = x +1;
}
// else, don't move
 

phillipPbor

Member
oH I think I get what you mean now!

Don't update the player in the conveyor belt objects, check for a conveyor belt collision in the player object instead

EDIT: pseudo code
Code:
inside player step event:
if there is a collision BELOW the player with obj_conveyorbelt {
    x = x +1;
}
// else, don't move
thanks...

well... lets see... i made a shaun formula so it can act like a platformer, however Benjamin helped out and replace the place_meetings with this code right here...
those are for both solid and jump/fell through platform collisions. i wonder if yal can add something that react to the convayors?

Code:
///checkCollision(x, y)

var xpos = argument[0];
var ypos = argument[1];

if (place_meeting(xpos, ypos, obj_platform)) // Check for collisions against normal blocks
  {
  return true;
  }
else
  {
  // Check for collisions against jump-through platforms
  var platform = instance_place(xpos, ypos, obj_jumpthrough_platform);
  if (platform == noone)
    return false;
  if (image_blend == c_red) // If it's in red mode, allow moving up through it, but not falling down
    return ((vsp > 0 and bbox_bottom <= platform.bbox_top) or (vsp == 0 and bbox_bottom < platform.bbox_bottom));
  else
    return (vsp <= 0 and bbox_bottom > platform.bbox_bottom); // When in cyan mode, allow falling through, but not jumping up or walking through it
  }

return false;

//by benjamin
 

Nux

GameMaker Staff
GameMaker Dev.
I don't think many people will be willing to code a large block of code for you.

But a lot are willing to give you advice: NightFrost has stated that the way they do conveyor belts is through a separate speed variable, externalSpeed. this speed variable would affect the movement of your player without the need to press any keys.

Example:
Code:
if is on conveyor
{
    externalSpeed = 2;
}
else
{
    externalSpeed = 0;
}

x += hsp + externalSpeed;
 

phillipPbor

Member
The way I have conveyor belts move player is to set up variables on player object for the effect. Call them External_x and External_y or whatever, and the conveyor sets values on them. Then the player step event adds them to hspd and vspd (or whatever you call them) and zeroes them. This way, the conveyor will not push the player inside objects if any are in the way, and doesn't need to do collision checking for the player because the player object will do it as matter of course.
i have a talk with Benjamin. your idea is pure... but please, let the player check for collisions with the conveyor, not the other way around.
 

TheouAegis

Member
I think I learned how it happened...
read this.
Aaaah! Never used multiple conveyors like that, always just one single object. That makes sense. Sorry I didn't catch that.

The problem with the player checking collisions is if you have two conveyors going opposite directions and the player collides with both at the same time. So there's two ways to handle that.
1) Only check for collisions near the front of the player (instance_position()) so that only one belt is taken into consideration, or
2) Check for all conveyors and ignore those that add nothing to the movement.

Example 1:
Code:
with instance_position(x+sign(hsp)*4, y+1, obj_conveyor) 
    other.x += scroll_speed;
Example 2:
Code:
var ride_speed = 0;
with obj_conveyor
{
    if place_meeting(x,y-1,other.id)
    if scroll_speed != ride_speed
        ride_speed += scroll_speed;
}
x += ride_speed;
 

phillipPbor

Member
Aaaah! Never used multiple conveyors like that, always just one single object. That makes sense. Sorry I didn't catch that.

The problem with the player checking collisions is if you have two conveyors going opposite directions and the player collides with both at the same time. So there's two ways to handle that.
1) Only check for collisions near the front of the player (instance_position()) so that only one belt is taken into consideration, or
2) Check for all conveyors and ignore those that add nothing to the movement.

Example 1:
Code:
with instance_position(x+sign(hsp)*4, y+1, obj_conveyor)
    other.x += scroll_speed;
Example 2:
Code:
var ride_speed = 0;
with obj_conveyor
{
    if place_meeting(x,y-1,other.id)
    if scroll_speed != ride_speed
        ride_speed += scroll_speed;
}
x += ride_speed;
okay... um (aham) one question... I'm confused... where should I post the examples at?
 
Last edited:

phillipPbor

Member
Look at the code and learn what the functions do. The answer will come to you. ;)
how can the code all fail? I mean... I tried everything
unless its a script you are looking at that page.

this is Benjamin's script.

um... may I remind you that the platformings are shaun spaldings.
Code:
///checkCollision(x, y)

var xpos = argument[0];
var ypos = argument[1];

if (place_meeting(xpos, ypos, obj_platform)) // Check for collisions against normal blocks
  {
  return true;
  }
else
  {
  // Check for collisions against jump-through platforms
  var platform = instance_place(xpos, ypos, obj_jumpthrough_platform);
  if (platform == noone)
    return false;
  if (image_blend == c_red) // If it's in red mode, allow moving up through it, but not falling down
    return ((vsp > 0 and bbox_bottom <= platform.bbox_top) or (vsp == 0 and bbox_bottom < platform.bbox_bottom));
  else
    return (vsp <= 0 and bbox_bottom > platform.bbox_bottom); // When in cyan mode, allow falling through, but not jumping up or walking through it
  }

return false;

//by benjamin
do the code theouaegis have for the player step event?
 
Last edited:

phillipPbor

Member
thanks to aaron plaxus.

you just had to use the place_meeting code.

Code:
if (place_meeting(x,y+1,obj_convayor_platform))
{
if (other.image_blend == c_red)
{x-=1}
else
{x+=1}
}
 
Top