Jump to content


Photo

Collision_Rectangle and solid objects


  • Please log in to reply
2 replies to this topic

#1 nanoviro

nanoviro

    GMC Member

  • GMC Member
  • 62 posts
  • Version:GM8

Posted 27 February 2012 - 05:31 AM

So on my boss level the boss is able to push you around. Everything seems to be working fine except for one small detail. There are some floating platforms (Obj_Wall1) that the boss sometimes can push you into. I thought that if I used collision_rectangle and defined the coordinates within the players object I could make the players object go up or down. For some reason though it is not working. Here is the code:
if collision_rectangle(bbox_left+1,bbox_bottom-1,bbox_right-1,bbox_top+1,Obj_Wall1,true,true) || collision_rectangle(bbox_left+1,bbox_bottom-1,bbox_right-1,bbox_top+1,Obj_Wall,true,true)
{
  y=y-1
}

Any help is appreciated. If you think the problem is outside of that code then tell where you think the problem lies and I can post or change that code. Thanks!


Note: I am using :GM8: Pro



Edit1:

Chances are this is because the object is getting pushed to xprevious and yprevious after this event. Try putting this in the endstep.

Edit: Hrm.. then again if you were in xprevious/yprevious this wouldn't occur. Darned moving solids again ;)
Btw, what is actually happening with this code?


This is the code for when the player collides with the boss
if place_meeting(x+1,y,Obj_Cloudmanbig) then hspeed=0
if place_meeting(x-1,y,Obj_Cloudmanbig) then hspeed=0
if place_meeting(x,y+1,Obj_Cloudmanbig) then vspeed=0
if place_meeting(x,y-1,Obj_Cloudmanbig) then vspeed=0

direction=other.direction
hspeed=other.hspeed

if bbox_bottom<428 && (place_meeting(x+1,y,Obj_Cloudmanbig) || place_meeting(x-1,y,Obj_Cloudmanbig)) && !place_meeting(x,y+1,Obj_Wall1)
{ 
y+=3
}


Other than that the boss does not affect the players speed or direction in any way. (As far as I can remember)

Edit2:
I just looked at my test code (I have a section for code that may or may not work in my step event) and realized I had this in there.
if place_meeting(bbox_left-1,y,Obj_Cloudmanbig)
{
 hspeed=other.hspeed
}
if place_meeting(bbox_right+1,y,Obj_Cloudmanbig)
{
hspeed=other.hspeed
}
if collision_line(x,y,x,bbox_bottom+1,Obj_Cloudmanbig,true,true)
{
 var obj;
 obj=collision_line(x,y,x,bbox_bottom+1,Obj_Cloudmanbig,true,true)
x += obj.hspeed
}

The second part is for when you are standing on his head. (Although due to the way everything works it may affect you while you are on his side)

Edited by nanoviro, 27 February 2012 - 06:41 AM.

  • 0

#2 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2295 posts
  • Version:GM7

Posted 27 February 2012 - 06:20 AM

Chances are this is because the object is getting pushed to xprevious and yprevious after this event. Try putting this in the endstep.

Edit: Hrm.. then again if you were in xprevious/yprevious this wouldn't occur. Darned moving solids again ;)
Btw, what is actually happening with this code?

Edited by greep, 27 February 2012 - 06:22 AM.

  • 0

#3 nanoviro

nanoviro

    GMC Member

  • GMC Member
  • 62 posts
  • Version:GM8

Posted 27 February 2012 - 01:57 PM

I am still having this problem.

EDIT: I solved the problem by adding it to the end step as previously mentioned... This is no longer a problem.

Edited by nanoviro, 27 February 2012 - 02:27 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users