Is this a correct way of using a blueprint interface?
Hi! For my game I stumbled upon an issue when my player slashed at an enemy. I eventually did a really crappy workaround where I made a variable called "Attacking" and made it true for 1/10th of a second, and if the player overlapped the enemy while slashing and that variable was true then it ran the hurt/hit function.
So what I did recently was create an interface called "Attacking" and implemented it onto the player and all the enemies. Inside I placed a function called "Slashing". In the slash event for the player I made it so that it fired that function for every actor that has it implemented, and then inside of the enemy's bp it would check if the player is within range, and if it is then do the hurt/hit.
Would this be a correct way of using an interface? Is this any costly? The reason why I didn't have the player just cast to the enemy and fire the hit event manually is for a few reasons, but I think that's besides the point :)
asked Apr 22 '15 at 03:17 AM in Blueprint Scripting
This seems like an odd way to implement a slash mechanic. Depending on the way your system is going to work i would maybe think of something like:
Otherwise that is a proper way to use an interface. Interfaces guarantee the a function will exist so its definitely a way to tell if something is what you are looking for. They are kind of crappy at sharing functionality though. If you want some shared functionality then components or parent classes may be the way to go depending on your situation.
answered Apr 23 '15 at 03:11 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here