• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! 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;}
 
For both sprites involved are the collision masks set up correctly? And are they both somewhat thick to prevent passing through.
 
Top