• 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!

GML Help! (Bouncing when hitting walls) Bad english

F

faser3m

Guest
Help!
I was trying to make a game (using tutorials online for the codes) where i could create an attack animation and, when hitting a wall for example, i wanted my character to bounce back, like he was being rejected (Like in hollow knight).

Actually, i made some progress with the cod and i got able to "sword-bounce" on the Y, changing my vertical speed:

if (!place_meeting(x,y,oEnemy))
{
with(oPlayer)
{
direction = other.direction;
vsp = -lengthdir_y(5,direction);
hsp = -lengthdir_x(5,direction);

}
}

This code works perfectly, but only with the Y. I can't bounce horizontally and i don't actually know why. i tried by just changing the X value of the player based on the bounce, and it works! Until i get too close to a wall and the bounce teleport me inside the wall, making my escape impossible.
If somebody can help, i can send whatever code you'll need...
Thanks.
 

Binsk

Member
What object is calling this code? Your code will make the player bounce in the opposite direction that the object calling this code is facing. If the player is not bouncing along the x then that is because the object calling this code is facing up or down the y.
 
Top