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"

Issue creating a Dodge function for an AI?

Hi all, so here's the trouble I'm running into:

I'm working on creating a melee AI for a game, and I'm having trouble getting a dodge function to work. For now, being a simple prototype all it really needs to do it jump back or step backwards a bit when the player attacks. It should do this randomly, though currently I am attempting to use Random Integer In Range to try and get a random call for it to dodge.

At the moment just for testing I am trying to get the character to simply jump when the dodge function turns on, but it never seems to work. Here is the a simple bit of scripting I'm using to try and get the player's input to have an effect on the AI character. In this case getting it to just jump if all the conditions match up.

alt text

It begins when the player is within the capsule around the character, the "Dodge Capsule", and ideally only runs if the playerIsAttacking bool returns true from the player's character blueprint. This isn't going to work because once the player enters the capsule the event is not going to fire again unless the player exits again and re-enters.

1). So the first issue is constantly checking to see if the player is within the capsule, probably using a linetrace to check within an area around the AI character (just like how the AI navigates to the player I would assume).

Would a custom event need to be created within the enemy event graph, then called from within the Player's event graph (say, on input via the left mouse button)? If so how is the best way of going about this?

2). The second issue is getting the AI to move backwards or jump backwards away from the player. I've thrown something together which probably, just probably won't work.

alt text

(The AI's navigation is straight from the Behavior Tree tutorial found here: https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/QuickStart/)

However, I've found this kind of method, using vector nodes, won't work because the AI's behavior tree seems to interfere with it. (Or overrides it entirely)

So this comes up to the third problem:

3). This entire thing needs to run off of the behavior tree.

When doing this I've run into problems, most of the time it simply refuses to run at all and the AI just stands there. This is a rough idea of what I think it should look like minus a service on the selector to decide whether to attack or dodge:

alt text

So to give a summary: How should I get the AI to respond to the player's input, such as a mouse click? Using custom events that run upon that input event?

What is the best way to make the enemy dodge randomly upon that player input? Is using integers in a random range the best method?

How is the best way to check if the player is near the AI and attack so as to determine whether to dodge or not? Would a line trace from the AI character within a certain radius be best?

To implement this into a behavior tree, does it require the adding of a third sequence to the two that are already there? (There is one already to make the AI move to the player, and another to make it go back to where it last saw the player. should the melee sequence one go in the middle?)

A lot of this is basically rubber duck debugging, easier to figure out when its typed out piece by piece or spoken out loud. But any help at all, even if its just a general workflow suggestion to get this working, would be very much appreciated!

Product Version: Not Selected
help_example_1.png (107.0 kB)
help_example_2.png (153.5 kB)
help_example_3.png (168.3 kB)
more ▼

asked Feb 24 '15 at 02:28 PM in Blueprint Scripting

avatar image

3 2 4 6

avatar image KrunkFu Feb 26 '15 at 05:13 AM

Have you tried turning it off and back on?

Seriously, I hope someone figures out how to do this because I'm working on a project that requires the AI to dodge and I have no idea how to do it.

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

0 answers: sort voted first
Be the first one to answer this question
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