R
Rare Truffle
Guest
Hey yo!
I've searched through the forum but couldnt quite find a fitting solution for my problem.
I hope one of yall can help me:
I am making a simple 2D Platformer on GMS 2.
I wrote a code, so if the player gets near "Obj_Block_1" the Player collides with the Object. In other terms it becomes solid.
I now want to use a different sprite/object e.g. a Block that looks different than "Obj_Block_1"... But I want it to have the same properties.
Whatever I do The player walks on "Obj_Block_1" but he falls right through every other object.
Maybe there is a way to sum up the objects into one var? I dunno :/
It would be awesome if somebody can help me understand this problem or even fix it
Btw here is my collision code:
//Collision
if (place_meeting(x + hspeed, y, Obj_Block_1))
{
while(!place_meeting(x + sign(hspeed), y, Obj_Block_1))
{
x += sign(hspeed);
}
hspeed = 0;
}
if (place_meeting(x, y + vspeed, Obj_Block_1))
{
while(!place_meeting(x, y + sign(vspeed), Obj_Block_1))
{
y += sign(vspeed);
}
vspeed = 0;
}
if (place_meeting(x + hspeed, y + vspeed, Obj_Block_1))
{
hspeed = 0;
vspeed = 0;
}
I've searched through the forum but couldnt quite find a fitting solution for my problem.
I hope one of yall can help me:
I am making a simple 2D Platformer on GMS 2.
I wrote a code, so if the player gets near "Obj_Block_1" the Player collides with the Object. In other terms it becomes solid.
I now want to use a different sprite/object e.g. a Block that looks different than "Obj_Block_1"... But I want it to have the same properties.
Whatever I do The player walks on "Obj_Block_1" but he falls right through every other object.
Maybe there is a way to sum up the objects into one var? I dunno :/
It would be awesome if somebody can help me understand this problem or even fix it
Btw here is my collision code:
//Collision
if (place_meeting(x + hspeed, y, Obj_Block_1))
{
while(!place_meeting(x + sign(hspeed), y, Obj_Block_1))
{
x += sign(hspeed);
}
hspeed = 0;
}
if (place_meeting(x, y + vspeed, Obj_Block_1))
{
while(!place_meeting(x, y + sign(vspeed), Obj_Block_1))
{
y += sign(vspeed);
}
vspeed = 0;
}
if (place_meeting(x + hspeed, y + vspeed, Obj_Block_1))
{
hspeed = 0;
vspeed = 0;
}