Forum Discussion

PointyL.Fish's avatar
7 months ago

Knock Back Player - Assistance - Much Appreciated!

Hello! I hope you're all doing well. I'm currently away from my computer but have my headset. I wanted to ask if someone would be able to  provide a clear breakdown with code blocks on how to implement a system where a player can pick up a sword, hit another player with it, and apply knockback? Since I'm using my headset at the moment, code block examples would be greatly appreciated. Thank you for your help! 

 

Cheers!

2 Replies

  • If I recall, that biggest issue with something like this was just apply enough push to the player on the Y to lift them off the ground while applying the knock back. What part are you needing help with exactly?

  • In my experience with making code block based knockback, I found it best to use a boolean at the start of the collision event to prevent it firing multiple times, also worth making sure the player being knocked back is not the same player holding the sword. We can turn the incoming motion of the sword into outgoing motion for the player by multiplying the relative velocity by -1. Taking it a step further, you can multiply this value by a number to scale up the knockback. Then, sending a delayed event to reset the boolean, you'll be set!

    One important note: you'll want to be sure 'Custom Player Motion' is toggled on for the world. This can be found in the 'Player Settings' of the world.

     

    It could look something like this when it's all done: 

    Happy creating!