#need some help with knocback effect

11 messages · Page 1 of 1 (latest)

sturdy steppe
#

i fixed the bug by changing += to -= but can someone explain why?

fair badger
#

this points towards the player

#

by changing it to -=, you essentially "reverse" the direction, hence making it point away

#

oh also

#

+360 is a full turn, and puts you back where you were

#

you might've meant to put +180

#

so

//add 180 to flip the direction
x+= lenghthdir_x(20, dir_player + 180)

or
//-= instead of +=
x -= lengthdir_x(20, dir_player) //+360 is unecessary

or

//flip the direction of point_direction
dir_player = point_direction(player.x, player.y, x,y)
...

x += lengthdir_x(20, dir_player)

do the same thing

sturdy steppe
#

oh ye...

#

i forgot that adding or subtracting 360 doesnt do anything