E
Evilperson
Guest
I'm making a platformer and the player character is a black rectangle.
For game feel purposes, I made the character get taller and thinner when it jumps.
A problem is that if I jump right next to a wall the player character gets thinner, and when the jump ends, it restores its original dimensions and gets partially stuck in the wall.
I tried solving this problem (marked as yellow text):
//Squash and stretch
if vspd < 0 {
if image_xscale > 0.8 {
image_xscale -= .05
}
if image_yscale < 1.2 {
image_yscale += .05
}
}else{
if image_xscale < 1 {
image_xscale += .1
if place_meeting(x-1,y,obj_solid){
x+=3
}
if place_meeting(x+1,y,obj_solid){
x-=3
}
}
if image_yscale > 1 {
image_yscale -= .1
}
}
This prevented the bug when hitting a wall to the left, but not to the right.
Also, when the player jumps next to a wall, and not into it, they move away slightly.
Please help
For game feel purposes, I made the character get taller and thinner when it jumps.
A problem is that if I jump right next to a wall the player character gets thinner, and when the jump ends, it restores its original dimensions and gets partially stuck in the wall.
I tried solving this problem (marked as yellow text):
//Squash and stretch
if vspd < 0 {
if image_xscale > 0.8 {
image_xscale -= .05
}
if image_yscale < 1.2 {
image_yscale += .05
}
}else{
if image_xscale < 1 {
image_xscale += .1
if place_meeting(x-1,y,obj_solid){
x+=3
}
if place_meeting(x+1,y,obj_solid){
x-=3
}
}
if image_yscale > 1 {
image_yscale -= .1
}
}
This prevented the bug when hitting a wall to the left, but not to the right.
Also, when the player jumps next to a wall, and not into it, they move away slightly.
Please help