I have been trying to make a small top-down rpg, where when an enemy gets hit by the player’s sword, they get knockbacked, but I haven’t been able to get it to work. I have seen and been following the tutorials called “Game Mechanic Breakdown - Enemy KnockBack - Part 1 + 2”, and “Game Mechanic Breakdown - Alerted Enemy - Part 1 + 2”, as well as “How To Add Melee Beat’em Up Combat To Your Game - GDevelop”, but it hasn’t been working. Does anyone know what I can do? Any help is appreciated
Also, if anyone knows a guide, either on here or on youtube, that shows how to make enemies respawn after you kill them, I’d also appreciate it a lot!!!
I’ve found permanent forces linked to animations can problematic. I tend to use an instant force linked to a variable ‘hurt’ and use a variable ‘hurt angle’ so that it slows down as ‘hurt’ decreases. We’ve all got our own methods and I can see the advantages of the method above but you do have to make sure you stop that force. You can also use an object timer to control the length of the knock back force. Experiment and see what works for you.
The method “hurt” variable and “hurt angle” variable seems very interesting and like it could work. If you don’t mind, could you share an image of how you do it? I tried it but I didn’t know how so it didn’t work.
sorry for a slow response. Basically this sort of thing.
i usually have a variable ‘hurt’ and ‘hurtangle’ and at the point of collision set the hurtangle for object A to be the angle from object B to object A and then set ‘hurt’ to however much you want it to move and stay hurt for. Sometimes like above i keep the recoil or knockback separate from how much it is hurt.
you can use the ‘recoil’ variable and times it by something or use any maths expression to achieve what you’re after. I looked back at all the knockback threads on the forum and there’s loads. There’s quite a few different ways by cleverer devs than me and so its worth looking at those as well!