Unreal Engine 4: Part 10 – Analogue Clock (Real Time Clock Blueprint)

Unreal Engine 4: Part 10 – Analogue Clock (Real Time Clock Blueprint)


Hey everyone and welcome back to part 10 of this game creation series So in this video, we’re gonna be creating an analog clock or a real-time clock, whatever you want to call it Let’s go ahead and jump right in. The first thing we need to do is import a clock mesh I’ve already made one in blender so as you can see, I’ve got the clock base the hour hand the minute hand and the second hand I’m gonna bring these in Now, of course you’d want to make folders for your assets so we can see we’ve got the clock mesh The image for the mesh and then the materials then we also have the hour the minute and the second hand as well So we’re going to use all these in a second So once you’ve imported your assets and if you want to use these assets I know they are very basic But you want to use them to test or use them in your project. There’ll be a link in the blog So go ahead and check that out So now let’s go to add new Blueprint class I’m gonna add an actor And then I’m gonna rename this clock Underscore blueprint again, you can name this whatever you want Now once we’re inside it we need to first add the clock base So you could go to add component and search for it, but it’s a little bit easier if we close this down Select the clock mesh Then open up the blueprint again Now when we go to add component and then type static mesh We can see at the bottom now, it has the name of the mesh that we want to add which is the clock So I’m going to click this So now I have the base. Let’s add some more things. I’m gonna close this down Let’s start with the hour hand select this one. I’m gonna do the same thing go back Then I’m gonna be able to add a component and then static mesh So now let’s do the same for the next one This one’s for the minute Now before I add this one in I want to make sure I select the clock Because this is going to be the parent if we had this one selected I think it would cause us some trouble when we rotate things. So make sure you have the clock selected Then we go to component and again type static mesh And then let’s do the last one Again make sure you have the clock selected then add component Now we have these in all we need to do is make it work. So let’s switch over to the event graph And we could do this a number of ways we could do this with variables. I’m going to do this very basic and simple I’m going to right click and then type event tick Then I’m going to drag this out and then I’m going to type delay Now this first delay is going to be for the second-hand Clothes change this to one then over in the component section here. I’m gonna select the second-hand and drag this out Then from here drag this out and we can type set relative Rotation Then we get these two options here. Well, we don’t need to change the location. We just want to change the rotation So I’m going to select this one Then let’s connect this up So now let’s go back to here drag this out and then this time we want to type get relative rotation Then on this pin if we right-click we want to split this struct pin, we know it’s the z-axis that we need So I’m going to drag this out and I’m just going to type + we can use float + float And then we just want to plug this back into here But we can see it’s not going to work since they’re not the same So I need to do is drag this out and then we can type make rotator Like this and then by default, it’s just plug into the X So I’m going to hold ctrl on the left click and just place this back into the Z which it should be And then we can plug this return value into the new rotation And if you want you can connect these up, but nothing’s going to change anyway, but it’s just just to keep it tidy I guess now before we can test this We just need to set this value here and this is going to act as the degrees of rotation So we just need to work out the degrees of rotation for each hand. I can easily work there I’m just gonna grab a calculator. So we say 360 divided by 60 It’s 6 degrees. So we should use 6 degrees Change this to 6 So I’ll compile that let’s go ahead and test this out now Just a little bit messy, make sure you tidy everything up Now we can grab the clock blueprint bring this in because it’s far too big And we also need to rotate it. Let’s go ahead and see if this is working. You just want to make sure it goes round and everything works fine, but that looks good to me now we can do the same for the other two hands something got back to the clock and Essentially, it’s just repeating this same process now also, if you don’t want your clock to go so slowly you just want to speed this up by reducing the number so I will select all of these Then I’m going to press ctrl W just to duplicate them So let’s plug this into the delay we know every 60 seconds we want the we want the minute hand to move So I’m just going to replace this one with this Plug this into here, plug this into here And then we can just delete this So for this one, actually the rotation can be the same compile that let’s go ahead and test this out now So we’re not going to see anything until the first hand has gone all the way around then We’ll see the next hand move a minute So you can see probably needs to be 59 rather than 60, but we can see it works so I’m just gonna go back Change this here. Go back to the delay. So it really should be 59. Obviously. I’ve got that wrong And again, I’m just going to do the same thing copy all of these ctrl W Connect this up I need to replace this one with the.. with the hour-hand Connect this up So we just need to change this now to 30 Compile it and then go ahead and test it So now we just need to set the delay For an hour, so that will be 60 seconds times 60 minutes, which would give you 3600 so if you wanted this to be accurate in real time, this would be 3600 Then you can compile it. But if we sat around waiting for this to work it take far too long So I’m just gonna speed these numbers up. So the last thing I’m gonna do is just go back to the viewport I don’t want them all pointing that 12 from default. So I select the hour Let’s go to the rotation this can start from let’s say 90 degrees which would be 3 o’clock. So They can go ahead and speed the up slow it down do whatever you want make it look a lot better than this But hopefully you enjoyed this video and hopefully enjoying the series if you are be sure to give this video a like as always Thanks for watching and I’ll see you in the next one!.

7 thoughts on “Unreal Engine 4: Part 10 – Analogue Clock (Real Time Clock Blueprint)”

  1. its a nice tutorial , but a little…… "ideal scenario"…. might be worth working as normal and manipulating hierarchies and parenting on the fly to help explain how to make right when things go wrong or weird. like, say , if you get parenting in the wrong order, show how to quickly fix it, or if you get the wrong axis, show how to fix it quickly.

    otherwise, amazing tutorial on a super handy technique and shows a lot of other stuff other than just the clock. how about a property to set the time and/or use the system time 😀

  2. Nice! I really must start playing with the Unreal Engine! I'm assuming (or maybe hoping) there would be some way to access the actual time, and use that to preset the clock so it displays current time? I actually built a (smooth-rotating rather than ticking) analog clock in a Half-Life Deathmatch map once, but it always started at the 12 o'clock position. It worked nicely, for what it was. Thinking about it now, I kinda wish I'd dug into the SDK to make a few enhancements for it… 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *