npruehs / ue4-rts

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

Issues/bugs, may I get some help, please? #177

Closed ForgottenFrog closed 2 years ago

ForgottenFrog commented 2 years ago

Hi! I've got some issues...I'm really trying to understand the code, but I still have issues with it...may I get some help, please? Whenever I ask a worker to build a construction, the worker gets stuck inside the construction and I cannot assign more workers to the same construction. If I ask a worker to gather resources, it works perfectly, but if I move the worker somewhere while he's getting back to the base, it's getting bugged, it becomes unable to get or drop resources anymore. Is there any command for resetting the number of carried resources? I can't find how to get the number of carried resources....

I'm sorry if the problems may sound a bit silly...but I'm still learning... ^.^

npruehs commented 2 years ago

Hey @ForgottenFrog,

that's multiple questions, so let's take a look at these one by one:

  1. What construction mode are you using, i.e. at the RTSConstructionSiteComponent attached to your building, what's the value of the Construction Cost Type? Also, what's the value of MaxAssignedBuilders?
  2. The worker should be able to drop resources at any building with a RTSResourceDrainComponent configured to accept the respective resources in its Resource Types. In any case, the number of carried resources is stored in the CarriedResourceAmount property of the URTSGathererComponent.
ForgottenFrog commented 2 years ago

Hi! Thank you for your reply!

I've managed to solve the workers problem. Sorry about that one, but the second problem is still there...

So...whenever I select a worker, I command it to mine, it gets the resources, goes to the base, drops them and then returns to the resource source. That's great, it works, but only if you don't bother the worker

Once the worker is carrying the max amount of resources and I cancel his command to drop them to the base (let's say I want to build something...), the worker is unable to collect or drop any resources anymore.

Once the return command gets cancelled, the resources can't be dropped, resetted or checked anymore.

And, regarding the resources, I spotted a problem (Idk if it's only my case...) The maximum amount of resources of a resource source can be changed, but the current amount cannot. And Idk why, but no matter how I change that number, if I use a simple print string to get the current resource amount, it is always starting with 1000.

npruehs commented 2 years ago

Well observed! Thanks for sharing!

The first issue is actually rather a misconfiguration: The order for returning resources was not added to the list of orders that can be issued via right-click. I've pushed a fix in https://github.com/npruehs/ue4-rts/commit/f6f885fa53f5e4d56605a834bf8e4e20301b366b, but you can quick fix that in your project by adding the order to the DefaultOrders array of your player controller blueprint. Note that the order of orders is important here - the ReturnResources order should be added right before the MoveOrder.

The second issue is a bug in the initialization of the current resources. I've added a fix in https://github.com/npruehs/ue4-rts/commit/f2099a6fcef2cc0a79edff04dfde7b1ba272b94a.

ForgottenFrog commented 2 years ago

Thank you for solving the problems! I really apreciate it.