x

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"

How do I create a Stun abliity?

I am fairly new to unreal and working on creating a stun ability but I am not sure where to being I know I have to working in the behavior tree but now sure what specifically I am supposed to do, if I could have any help or pointers on where to go that would be great.

Product Version: UE 4.21
Tags:
more ▼

asked Feb 08 '19 at 04:09 PM in Using UE4

avatar image

mattm109
1 1

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

I'd use a BPI to send the stun state from your player character to the enemy (when stun ability is used) and use stop all movement immediately, play stun animation and then have a delay for the duration.

more ▼

answered Feb 08 '19 at 04:18 PM

avatar image

Crowley Caine
643 8 9 15

(comments are locked)
10|2000 characters needed characters left

I'd use a BPI to send the stun state from your player character to the enemy (when stun ability is used) and use stop all movement immediately, play stun animation and then have a delay for the duration.

In the behavior tree you would check for stun state active and if it was, do the stun event.

more ▼

answered Feb 08 '19 at 04:19 PM

avatar image

Crowley Caine
643 8 9 15

avatar image mattm109 Feb 08 '19 at 04:23 PM

okay I also have never done a behavior tree before so this may be a bit difficult for me is there anything you recommend

avatar image Crowley Caine Feb 08 '19 at 04:36 PM

Do the official tutorial first to get an understanding of the basics: https://docs.unrealengine.com/en-us/Engine/AI/BehaviorTrees/QuickStart

avatar image mattm109 Feb 09 '19 at 09:46 PM

to be honest I don't really understand what you are saying nor do I have any idea on how to create an ability with my character to have it affect the enemy

(comments are locked)
10|2000 characters needed characters left

Fair enough. So lemme give you an example. I'm going to assume you don't have attack animations and capsules to utilize.

So first thing you want to do is add a sphere collision to your playable character blueprint. Just click the mest on the left side in the blueprint, click add component and choose sphere collision. Scale it up in the viewport to a decent size, say 50 or so just to have a good hit.

Next, go into your character blueprint and with the sphere selected, scroll down until you find "on component being overlap". Click the plus sign, drag out the "other actor" pin and choose promote to variable. Call that variable "Target". Then right click somewhere else, type in "1 keyboard" and choose the number 1 keyboard key.

Before we move on we need to do something you will find very helpful later. Go to your content browser and right click mouse over blueprints and create a blueprint interface (this is so that you don't have to cast to a specific enemy, all overlapping enemies may use this functionality). Call this blueprint interface something like "BPI_Event". Open the blueprint interface and in the already created function, just rename it "Stun".

Now go on back to your character blueprint and before we do anything else, we need to make sure your character can use that interface we created. So click class settings on the top bar, and in the interfaces tab on the left click "Add". Select the "BPI_Event" and we're good to go.

Now right click and turn off context sensitive, type in "stun message" and add that to your blueprint. This will message the function we are going to be using, ie triggering the event elsehwere. For "Target" drag in the "Target" we created. The result will look like this:

alt text

Now, you go into the blueprint of your enemy character, and you add the BPI_Event to class settings like we did before. Then you right click and type in "Event stun". That will receive the input from the message event and fire the function off.

Next I am going to assume your AI is working based on event tick. What you want is a way to disable event tick for a set amount of time, ie making the enemy immobile or "stunned" (can play a stunned animation if you want, let's not focus on that now).

So, add a variable to your enemy blueprint called "IsStunned". You drag it into your blueprint and choose "Set". Then you drag the execution pin off your BPI function and make it set the value to true. Then right click and search for "Stop movement immediately" for Character Movement, add that to your graph after you set the variable. Then you add a delay node, set it to 5 seconds or so, then you add in a "Set movement mode" node with your character movement as the target and set it to navmesh walking. Then you set the "IsStunned" variable to false.

Now you want to but a branch after your event tick, the condition being "IsStunned". If that is true, do nothing (or you can make it play the animation if you want). If it is false, connect that to the other behavior you may have. The result will look like this:

alt text

And there you have it. The enemy is now stunned for 5 seconds. Off the true branch from event tick (or before the delay node) you can add a play animation or play anim montage node if you want to play a stun animation. There are of course many ways of doing this and stunning several enemies will require some variations. I assume you will have some sort of ability to do the stun and then you can code a specific collision to it and have the enemy react by being hit by it, so you don't have to set a target etc (this will only hit one in a group of many, for many enemies you'd want an array and add all overlapping actors to that array).

stun01.png (75.2 kB)
stun02.png (85.5 kB)
more ▼

answered Feb 09 '19 at 10:21 PM

avatar image

Crowley Caine
643 8 9 15

avatar image mattm109 Feb 10 '19 at 06:12 PM

so this is what I have for my movement for my AI how can I adjust what you told me for this to work?

screenshot-63.png (96.4 kB)
screenshot-63.png (96.4 kB)
(comments are locked)
10|2000 characters needed characters left
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