• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Windows collision check not working

gekidoshi

Member
ok so my guy goes right through the walls

the code is

GML:
if (place_meeting(x, y, obj_Ground)) hspeed = 0
I also tried
Code:
if !place_meeting(x, y + 1, obj_Ground)
   {
   gravity = 0.01;
   }
else
   {
   gravity = 0;
   }
but that also doesn't work
 
If your gravity is pulling it down you are going to want to stop it with vspeed = 0 instead. Setting gravity to 0 just sets how much it accelerates per step. It doesn't actually stop it.
 

gekidoshi

Member
Can you post your code?
GML:
var lkey = keyboard_check_pressed(ord("A"))
var rkey = keyboard_check_pressed(ord("D"))
var ukey = keyboard_check_pressed(ord(" "))
var nkey = keyboard_check(vk_nokey)

///gravidade e colisoes
if !place_meeting(x, y + 1, obj_Ground)
   {
   gravity = 0.01;
   }
else
   {
   gravity = 0;
   vspeed = 0;
   }
///movimento
if lkey
   {hspeed = -5;}
if rkey
   {hspeed = 5;}
if nkey
   {hspeed = 0;}
 
Top