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.
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.
(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:
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!
asked Feb 24 '15 at 02:28 PM in Blueprint Scripting
Follow this question
Once you sign in you will be able to subscribe for any updates here