npruehs / ue4-rts

Real-time strategy plugin and showcase for Unreal Engine 4.
MIT License
747 stars 151 forks source link

Issue with Building Placement and AI #178

Closed magxmaDUCK closed 2 years ago

magxmaDUCK commented 2 years ago

For the Building placement, I have a unit (made from a character) that can build a house. The unit moves to the build site but randomly starts building or not. It also seems that the unit has a jitter uppon arrival at the build site. I have also tried the same with a unit using the RTSMovementComponent and have the exact same result.

For the AI, Well it simply doesn't auto attack other units in range. They only attack if I explicitly tell them to, and only attack the aimed unit. I have followed the Manual to make the units and the only difference is that i did not add the "RTSAttackableComponent" as it doesnt show up in the add component window, so I'm guessing it was changed with the gameplay tag.

I also wanted to thank you for this great plugin !

npruehs commented 2 years ago

Unfortunately, both of these sound like bugs I need to look into...

magxmaDUCK commented 2 years ago

I had a look in the C++ and it seems like auto-attack isnt pre made, I found the functions needed to do it however when looking for references to them there aren't any that come back, so i'm guessing the units not auto attacking is not a bug but is simply just not implemented ?

However for the building part I have yet to figure it out, it really is a random occurence. If I find anything I will keep you updated !

ForgottenFrog commented 2 years ago

Hi, I found the same problem. The AI perception is not implemented. In C++ it is mentioned, but never triggered.

npruehs commented 2 years ago

I can confirm this has been multiple bugs, actually. While you've been right in that the function FindTargetInAcquisitionRadius isn't called anywhere in C++, it's called in the behavior tree service RTSBTService_AcquireTargets. However, I've found a bug in that service that caused the AI to check whether the unit's target was valid (which is never the case while the unit is idle).

Then, I've found a second bug in how the AI was sweeping for nearby possible targets. I've added a configuration property Acquisition Object Types to the RTSPawnAIController that you need to set in your pawn AI controller blueprint (e.g. to WorldDynamic or Pawn, depending on the collision object types you're using for your units). I've updated the manual accordingly.

Fixed in https://github.com/npruehs/ue4-rts/commit/384c55198cd0a7cd3a444164c3e6936c02275783.