DanialKama / ThirdPersonShooter

Third-person shooter sample project developed in Unreal Engine 5
47 stars 6 forks source link

AI melee weapons support #42

Open tmedanovic opened 2 years ago

tmedanovic commented 2 years ago

Hi, first of all, great work!

Do you have any tips for implementing close combat? I spent few hours looking at your code. It slightly more complex then I used to work with.

Would it be correct to check for overlapping in here:

void AShooterAIController::HandleSight(AActor* UpdatedActor, FAIStimulus Stimulus) { ... Fight(); ... }

Thanks

DanialKama commented 2 years ago

Hi, for the solution I recommend adding a task to the behavior tree to check the distance between the AI character and the target, and if AI is close enough to the target, start a melee attack I will try to implement it

tmedanovic commented 2 years ago

Great, thanks!

You will probably have to refactor pickup weapon, and FireWeapon method or add another interface, maybe also adding is melee or something to weapon info.

I didn't work that much with behaviour trees, but wouldn't AI sensing trigger attack in HandleSight as I mentioned above when AI spots player?

DanialKama commented 2 years ago

I thought by close combat you mean punching and kicking, but if you going to add melee weapons, yes you have to refactor the Pickup Weapon actor or maybe create a child of the Pickup actor

DanialKama commented 2 years ago

About how AI characters aim and fire at a target, the current solution is bad, the better way to handle aiming and firing weapons is by using the behavior tree and not directly from the AI controller, So I may completely change the current setup

tmedanovic commented 2 years ago

Oh, both works, it's easy to adjust if you do it with close range weapon or kicks (for example just adding collision spheres to fists if you have close range weapon mechanics implemented or vice versa).

Looking forward to seeing your implementation using behavior tree if you decide to do it like that, learnt so much by looking at your code!