R
Raff
Guest
Hello,
I have the following code in the player step event that works:
But i wanted to try it in the object step event, so i tried this:
ob_prota1Idle is my player and ob_block is the object. Can someone, please, tell me what am i doing wrong ? Thankyou in advance.
I have the following code in the player step event that works:
Code:
if(moverY > 0)
{
var col1 = instance_position(x, bbox_bottom+moverY, ob_block);
var col2 = instance_position(bbox_left, bbox_bottom+moverY, ob_block);
var col3 = instance_position(bbox_right, bbox_bottom+moverY, ob_block);
var col = 0;
var colX = 0;
if(col1)
{
col = col1;
colX = x;
}
if(col2)
{
col = col2;
colX = bbox_left;
}
if(col3)
{
col = col3;
colX = bbox_right;
}
if(col)
{
while(!instance_position(colX, bbox_bottom+sign(moverY), col))
{
y += sign(moverY);
}
if(bbox_bottom < col.bbox_top)
{
moverY = 0;
if(state == states.falling) || (state == states.jumping || state == states.pillando)
{
image_index = 0;
if(keyDown)
{
state = states.crouched;
}
else
{
state = states.normal;
}
}
}
if(state == states.attackAir) state = states.attack;
}
Code:
if(ob_prota1Idle.moverY > 0)
{
var col = instance_position(x, bbox_top-ob_prota1Idle.moverY, ob_prota1Idle);
if(col)
{
while(!instance_position(x, bbox_top-sign(ob_prota1Idle.moverY), ob_prota1Idle))
{
ob_prota1Idle.y += sign(ob_prota1Idle.moverY);
}
if(ob_prota1Idle.bbox_bottom < bbox_top)
{
ob_prota1Idle.moverY = 0;
if(ob_prota1Idle.state == states.falling) || (ob_prota1Idle.state == states.jumping) || (ob_prota1Idle.state == states.pillando)
{
ob_prota1Idle.image_index = 0;
if(ob_prota1Idle.keyDown)
{
ob_prota1Idle.state = states.crouched;
}
else
{
ob_prota1Idle.state = states.normal;
}
}
}
if(ob_prota1Idle.state == states.attackAir) ob_prota1Idle.state = states.attack;
}
}