• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Problem with collisions

C

Caedmon

Guest
I am currently making an action platformer and i have problems with collisions. The code goes like this:
Create
Speed = 0
Step
var move = (keyboard_check (vk_right)) - (keyboard_check (vk_left))
speed = move * walkspeed
If (place_meeting(x + speed, y, wall))
{
While (!place_meeting (x + sign(speed),y,wall))
{
x = x + sign (speed)
}
Speed = 0
}
What it is supposed to do is stop me from going through walls but it stops me from moving if i am on top of said object.
How can i fix this?
 

marasovec

Member
That's because you are mixing variables "Speed" and variables "speed"
I always use names without capital letters to avoid these mistakes
 
C

Caedmon

Guest
That's because you are mixing variables "Speed" and variables "speed"
I always use names without capital letters to avoid these mistakes
I am currently on my phone and wrote this from memory.
It is fully capitalized correctly in the original version
I know this because the original variable is hsp standing for horizontal speed

Edit: I may have solved the issue
I placed thousands of walls instead of extending one...
 
Last edited by a moderator:
Top