npruehs/ue4-rts

Video tuto ?

Opened this issue · 3 comments

kevld commented

Hello @npruehs ,
Your plugin is very interesting and usefull, I discover it few days ago and I am testing it.
Is there an existing video which explains how to use the plugin ?
I think there is something I don't understand with AI units and AI players. My units are moving but I'm unable to make them attack other units (I double check gameplay tags but maybe I miss something)

Hey @kevld !

Unfortunately, a video tutorial is on my todo list, but I didn't find the time to create some yet.

Do your units belong to different players, and are these players in different teams?

kevld commented

Hi @npruehs, thanks for answering me :)

Here is what I did
I created 2 player start points (inherited from RTSPlayerStart). One for p1, the second for AI (p1 in team 0, AI in team 1)
image

After that in the level blueprint, i did this :
When I hit "H" key (for debug purpose of course), a unit spawns and i transfer ownership to the first player. This part works
image
I tried to do the same for the AI when I hit "J" but it's not working :
image
I tried several things, including this (also tried with other player indexes):
image
With same result
I think it is in this part that there is something I miss (probably even UE4 basics...)

When I Test it, I am able to move my unit, and not able to move enemy unit. this is OK. But my unit is not attacking, The issue order passed is always a move order, even if I right click on the enemy unit
Here is a demo :
https://youtu.be/Xmav8TjJbqk
The first unit to spawn is "my" unit
The second one is the AI's unit

Here is my character's components (the character inherits from the UE4's Character class) :
image
Gameplay tags on RTSGameplayTags component :
image
Gameplay tags on RTSHealth component :
image
Gameplay tags on the RTSAttack component :
image

I tried to add the Relationship.Hostile tag but it did not help

The main problem is located between the keyboard and the chair... I'm pretty sure I miss something basic

Get Player Controller with player index 0 works for you, and returns a valid player controller, because it's a built-in helper function that just takes an index returns a player controller - as expected.

Get AI Controller takes an actor as argument, and is supposed to be passed a pawn controlled by an AI controller. This has originally been built by the engine team for getting the AI controller of a bot in Unreal Tournament. Thus, your attempt in passing a player start and getting its AI controller failed.

The same is true for accessing the player controller with index 1 and passing it to Get AI Controller: Player controllers and AI controllers are mutually exclusive - in fact, they both extend the same base class: Controller. Thus, in fact, even if any of your attempts to get an AIController had been successful, casting the result to your player controller blueprint is deemed to fail.

I recommend reading up on the engine basics, more specifically, its game framework: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Framework/