W
wesk1288
Guest
Hey everyone, first time posting in GMC and I'm a total beginner.
In my game, I have a basic moving platform that when when the player stands on it, his speed matches it and he moves with it. That's all working fine. However, when I try to duplicate the platform obj. and place more of them into my room, only one of them works (the most recent one created). All of the platforms still have the collision and left and right movement but the player no longer matches his speed with the platform (except for the most recent one created).
What am I missing here? Thanks in advance for any help. Here is the code of my Obj_Platform:
Create Event:
randomize()
dir = choose(-1, 1);
Step Event:
//Platform Movement
x += horizontal_speed * dir;
if(x < position_from || x > position_to) {
dir *= -1;
}
//Player Detection On Platform With Movement
if(place_meeting(x, y-1, Obj_Player)){
Obj_Player.speed = horizontal_speed * dir;
} else {
if(!place_meeting(x, y-1, Obj_Player)){
Obj_Player.speed = 0;
}
}
horizontal_speed, position_from, and position_to are all set in the variable definitions of my object.
In my game, I have a basic moving platform that when when the player stands on it, his speed matches it and he moves with it. That's all working fine. However, when I try to duplicate the platform obj. and place more of them into my room, only one of them works (the most recent one created). All of the platforms still have the collision and left and right movement but the player no longer matches his speed with the platform (except for the most recent one created).
What am I missing here? Thanks in advance for any help. Here is the code of my Obj_Platform:
Create Event:
randomize()
dir = choose(-1, 1);
Step Event:
//Platform Movement
x += horizontal_speed * dir;
if(x < position_from || x > position_to) {
dir *= -1;
}
//Player Detection On Platform With Movement
if(place_meeting(x, y-1, Obj_Player)){
Obj_Player.speed = horizontal_speed * dir;
} else {
if(!place_meeting(x, y-1, Obj_Player)){
Obj_Player.speed = 0;
}
}
horizontal_speed, position_from, and position_to are all set in the variable definitions of my object.