I'm having a problem making collisions using my own script.
Mario falls through the ground when I turn on treat uninitialized variable as 0 in the global game settings so I turned it off. If I turn it off, I get an error
:
Quote:
___________________________________________
ERROR in
action number 4
of Step Event
for object obj_mario:
In script col_rect:
Error in code at line 2:
if argument0 > block.bbox_left //x1
^
at position 23: Unknown variable bbox_left
I used this code for my script:
Code:
block = collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_solidground,1,1)
if argument0 > block.bbox_left //x1
or argument1 > block.bbox_bottom //y1
or argument2 < block.bbox_left //x2
or argument3 < block.bbox_top //y2
return false;
else
return true;
I use it in the step event:
Code:
if col_rect(bbox_left,bbox_bottom,bbox_right,bbox_bottom+yspeed+1,obj_solidground)//collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom+yspeed+1,obj_solidground,1,1)
{
topblock = collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom+yspeed+1,obj_solidground,1,1)
if yspeed > 0 and y+sprite_height < topblock.bbox_top+1
{
y = topblock.bbox_top-31
yspeed = 0
grav = 0
jumpnow = 0
}
}
else
{
if yspeed < -2
grav = 0.1
else
grav = 0.3
}
Is there a way to fix it?
I'm having a problem making collisions using my own script.
Mario falls through the ground when I turn on treat uninitialized variable as 0 in the global game settings so I turned it off. If I turn it off, I get an error :blank: :
[quote]
___________________________________________
ERROR in
action number 4
of Step Event
for object obj_mario:
In script col_rect:
Error in code at line 2:
if argument0 > block.bbox_left //x1
^
at position 23: Unknown variable bbox_left
[/quote]
I used this code for my script:
[code]
block = collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,obj_solidground,1,1)
if argument0 > block.bbox_left //x1
or argument1 > block.bbox_bottom //y1
or argument2 < block.bbox_left //x2
or argument3 < block.bbox_top //y2
return false;
else
return true;
[/code]
I use it in the step event:
[code]
if col_rect(bbox_left,bbox_bottom,bbox_right,bbox_bottom+yspeed+1,obj_solidground)//collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom+yspeed+1,obj_solidground,1,1)
{
topblock = collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom+yspeed+1,obj_solidground,1,1)
if yspeed > 0 and y+sprite_height < topblock.bbox_top+1
{
y = topblock.bbox_top-31
yspeed = 0
grav = 0
jumpnow = 0
}
}
else
{
if yspeed < -2
grav = 0.1
else
grav = 0.3
}
[/code]
Is there a way to fix it?