I need help.

L

lnb819

Guest
My character can only collide with "oWall" I need to make it to where it can also collide to "MovingPlatform"

Heres The Code:

//get player input
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);

//get player movement
var move = key_right - key_left;

hsp = move * walksp;

vsp = vsp + grv;

if (place_meeting(x,y+1,oWall)) and (key_jump)
{
vsp = -7;

}

//Horizontal Collison
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x +sign(hsp);
}
hsp = 0;
}
x = x + hsp;

//Vertical Collison
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+sign(vsp),oWall))
{
y = y +sign(vsp);
}
vsp = 0;
}
y = y + vsp;

//Animation
if (!place_meeting(x,y+1,oWall))
{
sprite_index = sPlayerA;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = sPlayer;

}
else
{
sprite_index = sPlayerR;
}
}

if (hsp != 0) image_xscale = sign(hsp);
 

FrostyCat

Redemption Seeker
Im Still A Noob To Game Maker. What do you mean?
Scroll down on that page and read the section labelled "Parent". Being new doesn't give you an excuse to not read instructions.

When you assign object A as a parent to object B, in a collision situation checking for A will also check for B. In your case, either set oWall as the parent of MovingPlatform, or create a new object to serve as the parent of both and check for collisions with that.
 
Z

zecton

Guest
go to the moving platform object and then make it son of the owall (that option is bellow the sprite selection in the object menu)
 
Top