Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 :)

Thank you!

Product Version: Not Selected
more ▼

asked Apr 22 '15 at 03:17 AM in Blueprint Scripting

avatar image

331 46 64 74

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

  1. Do a box trace in front of character and return all hit actors of correct collision/trace channel. This would be triggered by either a timer or an animation notify to tell you the proper point in the swing to check.

  2. Actually detect if the weapon overlaps a mesh after setting Attacking to true.

  3. Build a custom collision component and check it for overlapping at the time of attack.

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.

more ▼

answered Apr 23 '15 at 03:11 AM

avatar image

2.6k 98 16 97

avatar image jfaztk Apr 23 '15 at 03:18 AM

Thanks! I don't really care about shared functionality; in fact I want each function to perform differently. I actually already did all that, but an issue with "Attacking" being set to true is that it stays true for too long, so sometimes the damage function fires more than once >.< Using interfaces I get one guaranteed output; just like if I were using input events.

avatar image jfaztk Apr 23 '15 at 03:29 AM

Whoops! forgot to say my game is a 2D platformer; there are no anim notifies with Paper2D, I believe.

avatar image RimmyD Apr 23 '15 at 05:56 AM

Oh hmmm, I really have no experience with Paper2D.

Could you:

  1. Check to see if you are overlapping another sprite

  2. Verify the hit sprite is in front of the character

  3. Check the hit sprites interface

I guess in the end it matters if you want to have continuous detection or a single moment of detection at the top of the slashes arch.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question