Jump to content


Photo

GML Gravity and Collision Help


  • Please log in to reply
1 reply to this topic

#1 FoGownz

FoGownz

    GMC Member

  • New Member
  • 9 posts
  • Version:GM8

Posted 26 April 2012 - 05:17 PM

This is my code for gravity. It works to the point where my object will fall if it's in mid air, but it doesn't stop when it collides with the floor. Instead it keeps falling until it hits the bottom of the room and then stops. Can someone help me with this?

{
if place_free(x,y+1)
{
gravity = 0.5; gravity_direction=270
}
else
{
gravity = 0
}
if collision_point(x,y+1,obj_wall,1,1)
{
gravity = 0; gravity_direction=270; move_contact_solid(270,4);
vspeed = 0;
}
}


PS: Please excuse my noobiness, I just started messing with GML today.
  • 0

#2 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1464 posts
  • Version:GM8.1

Posted 26 April 2012 - 06:16 PM

try this:

if!place_meeting(x,y+vspeed+1,obj_wall)
{
gravity = 0.5; gravity_direction=270
}
else
{
gravity = 0; gravity_direction=270; move_contact_solid(270,abs(vspeed));
vspeed = 0;
}
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users