Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Rts how to add a construction time to buildings?

I'm working on an rts practice project and I'm pretty stuck on adding a construction time to my actors.

Right now I have a setup where the actors are bound to hud buttons, I click them they spawn in the world and follow your cursor, right click to cancel, some buttons mapped to rotation and they are transparent green if they can be placed and turn transparent red if they are on a slope or overlapping.

I'm trying to make it so when I click on the hud to spawn a building (this makes buildmode active) and then place in the world this will make the mesh transparent and have "x" amount of time and the building will be "built". I'd like to eventually have a resource requirement for the buildings and make it so a worker has to build it. And have it go through multiple build meshes depending on completion %.

But for right now I'd just like a set value for the build time that could be changed depending on the mesh and would work with my ingame time.

This is probably the most stuck I've been on this project since trying to learn ue4 so any help appreciated.

Product Version: UE 4.21
more ▼

asked Nov 12 '18 at 06:46 PM in Using UE4

avatar image

30 1 3 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first


You can use the timer nodes for this. You can have the timer fire off a custom event (or bind it to an existing one) that will happen after the time you specify.

Additionaly, if you set the timer handle to a variable, you can interact with it as well.

alt text

ue4-demo-timers.png (243.5 kB)
more ▼

answered Nov 12 '18 at 07:40 PM

avatar image

111 2 3 4

avatar image PerCat Nov 13 '18 at 05:26 PM

That would be able to work with the ingame time and eventually actors right? Thanks for the help so far

avatar image gryphen_76 Nov 13 '18 at 06:52 PM

Yes, it should be compatible with game time. And you can reference an actor as shown, so you can call a specific event in that actor when the timer fires. Although I would recommend putting the timer in each actor's blueprint so it's handled automatically after placing the building.

Something like an event in the building's blueprint that starts the timer after the building's been placed.

avatar image PerCat Nov 14 '18 at 04:57 PM

Would you happen to know why this isn't working? The building ghost ref is the transparent mesh that gets placed in the world first, but after I click to place it changes to solid mesh.

alt text

screenshot-30.png (984.1 kB)
avatar image gryphen_76 Nov 14 '18 at 07:54 PM

So after the actor is spawned, (time * 60) seconds will pass before the Construction_Completion_Rate event is fired. That event will then increment CompletionProgress (add 1 to it then set it).

So after your event fires, CompletionProgress is going to be at 1 (assuming your default value is 0). When you convert a float to a string, you will get "1.0", which your SwitchOnString will not find. Generally converting floats to strings to perform a float operation is not a good idea.

Why your mesh is changing to solid after you place I can't say, because there's nothing in this blueprint that would do that, considering your SetStaticMesh Nodes have no way to execute.

I would recommend a different approach, as shown below: alt text

avatar image PerCat Nov 15 '18 at 04:35 PM

Wow. That is above and beyond man. I can't thank you enough. Seriously thanks. I'm still really new to all this and have been stuck on this FOREVER. So just wow, thanks.

avatar image gryphen_76 Nov 15 '18 at 04:52 PM

Happy to help, have a good day!

And please, if the answer worked for you, can you mark it as accepted? Thanks!

avatar image StyloProx Jan 08 '19 at 05:24 PM

Sorry, i'm still learning eu4, but how do you then implement this to your child blueprint and set all the stages? Tried different solutionsbut, but i haven't quite figured it out.. :/

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I think that's a good solution, but I wondered if it could be done without using Event Tick. So I did this:

alt text

I think it should work... NOTE: SegmentNumber should be initialized as 0.

more ▼

answered Nov 15 '18 at 05:13 PM

avatar image

llll Sabre llll
30 1 2 5

avatar image gryphen_76 Nov 15 '18 at 05:25 PM

That way works too. :) And if tick is an issue, you can always disable it after the building completes using SetActorTickEnabled.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question