x

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"

I would like to record the number of frames from the start of an event to the end, possibilities?

I would like to record the number of frames from the start of an event to the end, no animation for now. On a side note, trying to understand how the frame skip works after hitting pause in the menu. Something like playing while using frame skip would be nice. Also wanted to mention I am the greatest of newbs so forgive me if my question is elementary.

Product Version: UE 4.21
Tags:
more ▼

asked Dec 13 '18 at 03:41 AM in Blueprint Scripting

avatar image

HydroWin
3 1 3

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

HydroWin,

One way to do it, would be to set up a blueprint, that when the event occurred would start counting frames. Remember there is a call to event tick for a blueprint for each frame. So a simple method would be to just increment a counter for each call to the Event Tick. You would also want to have a bool that fed into a branch node, to act as a trigger, for when the Event started so you could start counting, and flip the bool to false, when the event was done, then have the count dumped out to the log via a Print node. Again this is very simplistic, but would do what you are looking for.

Hope this helps,

Jay

IceWare

more ▼

answered Dec 13 '18 at 03:54 AM

avatar image

jayice
1.4k 41 28 56

avatar image HydroWin Dec 13 '18 at 01:49 PM

This method sounds ingenious but wouldn't that effect the performance? I'm planning on having this happen across multiple events. Or do you think it won't have that big a hit on performance if I connect the event tick to a sequence and then to all the events I plan on having?

avatar image jayice Dec 13 '18 at 09:58 PM

In terms of performance, there will be a negligable impact. Using the tick, is not inherently going to sacrifice performance, it's how much work you do during the tick, that impacts performance. Just checking a few booleans to see what event is active, and incrementing a counter will be negligible at worst, and at best, there will be no impact at all.

So what you will be doing, or how I would code it, is that I would have one blueprint, that is external to all the code that starts/stops the events. Then hook up how you wish to notify (I would just use a function call) the recording BP for the particular event. Create one bool per event type, and when the event fires, notify the recording blueprint, and tell it the type of event, so that the bool for the event will return true. In the code that sets the bool in the recording blueprint, enable the tick at that point.

Now the tick processing will start firiring, allowing you to start the counter for that bool. When the event is done, call again to the recording to have it turn off the counting for that bool, dump out the information you wish. AFTER the bool is turned off, OR all the bools together, if it is false, then disable the tick as well.

Hence the recording blueprint, will not impact performance at all, unless there is an active event that is having the frames counted for it.

Hope this helps,

Jay

IceWare

avatar image HydroWin Dec 14 '18 at 03:34 AM

My word, how are you this great?! Anyway, I think I got what I was looking for based on your answer. I didn't make it into its separate function just yet to make it easy on my brain but I set a variable to increment by 1 that's attached to the event tick node. I then set that variable to 0 when my other event is pressed changing the variable back to 0 and finally calling it after releasing the button.

I took a couple screenshots so you can melt your eyes and shake your head in disappointment at it but so far it seems to work. Might not perform well but I'll eventually make everything cleaner once I at least get everything working. But for now I'm making spaghetti blueprints, thanks again for the help I appreciate it!

ue4.png (174.4 kB)
ue4.png (64.1 kB)
avatar image jayice Dec 14 '18 at 04:52 AM

I wish I was that great! lol, far from it. Yeppers, it looks like the code should do what you want. A couple of points. (and the points are all just nit picky, but it's good to train yourself to do it, without thinking about it)

  1. In the event graph, use the increment node, instead of the add node. This way you will bypass needing to do the set. Note on the increment node, that the input is a Diamond pin, meaning that it's a reference being passed, hence the node actually is incrementing and setting the variable reference.

  2. For something like a counter, use Integers instead of floats. While processors have advanced a long way, the CPU still is faster at working with integers than it is floats.

After looking at your code, it would seem that you are actually after the period of time that the keypad button was held down, not really after the number of frames. In order to generate this in a different fashion. Just take the same accumulator (it's already a float, and should stay a float), and add to it the Delta Seconds that is passed from the Tick call. The rest of your code should not have to change. Then when your getting the message displayed, it truely will be the amount of time the button was held down, and you will not need to bother with the "Framerate to Seconds" call etc.

In terms of having this all in a function. I was really thinking in terms of having it in another blueprint. The reason for this, is that when starting to get performance/event/counter information, it's easy to start adding to it, and it begins to grow quickly, and then it's all over the place in the actual product, making it more of a pain to remove later on. If it's all contained in a external piece of code ( in this case a blueprint), only the calls to the blueprint need to be located, and removed from the product. Far less error prone.

Hope this helps,

Jay

IceWare

avatar image jayice Dec 14 '18 at 02:21 PM

I wish I was that great! lol, far from it. Yeppers, it looks like the code should do what you want. A couple of points. (and the points are all just nit picky, but it's good to train yourself to do it, without thinking about it)

  1. In the event graph, use the increment node, instead of the add node. This way you will bypass needing to do the set. Note on the increment node, that the input is a Diamond pin, meaning that it's a reference being passed, hence the node actually is incrementing and setting the variable reference.

  2. For something like a counter, use Integers instead of floats. While processors have advanced a long way, the CPU still is faster at working with integers than it is floats.

After looking at your code, it would seem that you are actually after the period of time that the keypad button was held down, not really after the number of frames. In order to generate this in a different fashion. Just take the same accumulator (it's already a float, and should stay a float), and add to it the Delta Seconds that is passed from the Tick call. The rest of your code should not have to change. Then when your getting the message displayed, it truely will be the amount of time the button was held down, and you will not need to bother with the "Framerate to Seconds" call etc.

In terms of having this all in a function. I was really thinking in terms of having it in another blueprint. The reason for this, is that when starting to get performance/event/counter information, it's easy to start adding to it, and it begins to grow quickly, and then it's all over the place in the actual product, making it more of a pain in the butt to remove later on. If it's all contained in a external piece of code ( in this case a blueprint), only the calls to the blueprint need to be located, and removed from the product. Far less error prone.

Hope this helps,

Jay

IceWare

avatar image HydroWin Dec 14 '18 at 07:38 PM

The level of detail your providing is too great for me but I think I understand. I used the increment node instead of the extra nodes I had and it's looking muuuuuuch cleaner. And here I thought all number variable types were equal in performance, silly me. Also I do want the number of frames that passed, unless the period of time is the same thing? I'm also not sure how to write if the number of frames is under 10 then do something else in a different way without using the framerate to seconds node. I get what you mean by having it in another blueprint, I will focus on making it more readable soon, things like using increments definitely made it less confusing for sure!

avatar image jayice Dec 16 '18 at 10:31 PM

If the framerate is all that important to you, remember that the tick event is being called once per frame, hence your Dash Frame Count is already the frame count.

To get the number of seconds, create a float variable, and use it as an accumulator, adding in the delta seconds that is passed in to the event tick.

So your Dash Frame Count, now holds the number of frames, the accumulator holds the total time. You can then of course, divide the frame count into the accumulator, to get an average time for each frame. You can as well, keep a high and low value from the delta seconds, or any gradiant there of, so that you can also check to see if the Delta Seconds, is falling close to the median, or to an average etc. No matter what you do, you can get the values that you are looking for, without having to hard code the "60" into that FrameRate to Seconds node.

Hope this helps

Jay

IceWare

avatar image HydroWin Dec 17 '18 at 08:11 PM

Each response you give sounds more and more like you developed Unreal yourself lol. I never thought to get the denominator that way but on the other hand I'm still a newb. I only hardcoded it to 60 because in the general settings I fixed the frame rate to 60 but from what @Tuerer said on the second answer, the frame rate will depend on the users PC and what they are doing so getting the average from delta will help. Thank you again!

avatar image jayice Dec 17 '18 at 10:48 PM

lol, no I have only rooted around inside the code of unreal a bit. the thing is that any system that is sufficiently complex starts looking like any other system. I.E. I have worked on OSes, written database engines, device drivers, etc. UE4 reminds me of a OS the most. Although it's dependency on one main thread to run the majority of the engine, lacks a lot to be desired. Especially in today's multi-core cpus. Because this causes an inherent bottle neck.

Focusing on the framerate, is something that I think too many people do. I am not stating that the framerate is not important, but it's like the "tail wagging the dog". The framerate is the culmination of 100's of actions within the engine. To substantially alter the framerate, one has to use the "STAT" command while running the game itself, and then see where the majority of the time is being spent. Then focus on that, to get the biggest bang for the time spent. Getting a baseline framerate is desirable, so that as the code is changing, you can do a quick check, with just one number (framerate) to see if new code has altered what is occurring substantially.

Stay focused on what your trying to accomplish, to deliver a game that people enjoy playing, and that gives 90 to 95% of those people a lot of fun. Most of those people are going to have 60Hz monitors, which can display a framerate of 60fps, and no more. So trying to drive the frame rate up to 240 FPS for example, is not of great value to the vast majority of your customers.

Hope this helps.

avatar image HydroWin Dec 18 '18 at 04:43 AM

I'm convinced you and Bill Gates go out for tea on Tuesdays. You've made so many great points, I am soaking it all in. I think Node.JS is a little complex but not to an OS level, I find a database engine fascinating. I heard SQLite is the way to go for folks that want to have a deeper understanding of how it works back there. Would you suggest having a deeper understanding of something complex like that or OS sufficient enough to understand what's possible in Unreal?

Yes I agree, I'm only focusing on the tip of the iceberg but I have to start somewhere right? I mean it isn't something like a fighting game where precision makes or breaks it but it just one of those things players won't need to complain about constantly. You've helped me so much, very glad Unreal has people like you in it. I'm going to put what I learned to work.

avatar image jayice Dec 18 '18 at 01:13 PM

I refused to meet bill gates, besides I always felt that Steve Ballmar was the " real man behind the curtain" lol. Personally I would suggest, reading the 3 tomes by Donald Knuth (The Art of Computer Programming, Volume 2 can generally be skipped, but Volumes 1 and 3, cannot, and there are more volumes now). These will give one of the finest groundings in computer programming, independent of a programming language (Knuth uses a hypothetical assembly language to illustrate everything). Being independent of a programming language, is a great objective as well.

Consider that as soon as one, understands the concept of a fork, and how to use it to eat. That one is enabled to use any fork, to eat with. So why do people become so enamored with a language I do not understand. The only languages I became enamored with were, IBM System 370/390 Assembly, and Intel 80xx Assembly language. I've forgotten more languages than most others will ever learn, because they come and go like the seasons of the year, but Assembly, for the major processors of our lives, do not change.

So get at least two of the books (Ebook it is much cheaper), and just dive right into UE4 itself. The source code is there, made available by Epic (And huge kudos to Epic for this), so I would suggest starting where you wish to be anyway! Remember, because you have the source code for the engine, you can change it to do anything you wish.........................

I have no degree, I just started with Knuth, and IBM System 370 Principles of Operation (yes it's still available as well, and the FINEST description of a computer architecture you will ever read). Just like with any sport, become well grounded in the fundamentals, and everything else will fall in place. Then one day, you may look at the latest and greatest whizbang language to hit the market, and think to yourself, "This is an abomination!!!!!" (Just like I did with C++, and others)

Hope this helps

Jay

IceWare

avatar image HydroWin Dec 19 '18 at 05:04 PM

lol Steve Ballmar, we are talking about the man that owns the Clippers? Hmm haven't read to much about him but from what I have read, he definitely seemed to be pulling strings. The wisdom you carry is great, I will most likely start reading volume 1 next week when I have time off. I whole hardheartedly agree which the multiple programming languages, which is best? I guess that depends on how flexible it is. I didn't bother editing the engine at all because I lack the knowledge but hopefully by the 3rd or 4th quarter next year, I'll be armed with enough background to create something wonderful. I can't stress this enough, thank you!

avatar image jayice Dec 19 '18 at 05:46 PM

Remember, Ballmar was the gentleman that dropped his pants and stood on stage, only wearing his underwear, to get people's attention!!!!!

Yeppers, read volume one, and don't skip volume 3, it's amazing how many problems can be solved with a sort,and of course Searching is very important (Especially in working with compilers, during the lexical analysis, and you would be surprised at how many times, I have created tiny lexical analyzers in order to extend features of products).

Of the programming languages that are available there is a General Best, which I would tend to say is C, if one wants cross platform comparability. After that, the languages boil down to what are they each designed for? String handling? Numerical computation? (Probably nothing beats Fortran for this), still most of this will resolve to how the libraries are set up. Not so much the language itself.

I still think, that anyone wishing to be a programmer, should still understand the machine, hence don't overlook Assembler. It will teach you more about programming than any other language. Because you have to do everything yourself, instead of relying on libraries, etc.

Assembler will also allow you to find ways, to make things more efficient. Take the lowly "Branch", without a doubt, the most executed flow control there is. Why can I say this? because there is in truth no other flow control instruction for general purpose processors.

Cmp ValA, ValB Jmp/Br OnEqual

So looking at those two little instructions. Do you code it, so that the Jmp/Br will fail the majority of the time? So that the code will just "fall through" on the failed Jmp/Br? What is the fastest way to execute this? For the majority of times, that this compare is executed? When you start thinking like this, naturally, you code is automatically being optimized, without any extra effort.

Anyway, just some thoughts, hope you have a great day, and all the best to you!

Jay

IceWare

(comments are locked)
10|2000 characters needed characters left

in the BP containing your event, I'd just add an INT variable, increase it by one in your event using ++ or +1... the final value of your INT variable will be the number of frames

you could use PrintString to show the result on screen

more ▼

answered Dec 13 '18 at 04:00 AM

avatar image

aNorthStar
878 7 17 19

avatar image HydroWin Dec 13 '18 at 02:16 PM

Hmm but how does one know how fast it is incrementing? Does it increase per frame by default? Here is a screenshot of how I am imagining your answer.

ue4.png (61.9 kB)
avatar image Tuerer Dec 13 '18 at 02:45 PM

"++" only works if you activate it. You have to "get" Intvar and connect it to ++ input, and place that ++ after Gamepad Left Trigger. In your case the Intvar won't increase.
And if you want the framerate, you have to hook that up to Event Tick, as per @jayice 's sugestion. E.g., set a gate: when Gamepad Left Trigger is pressed — open the gate, when unpressed — close. And feed Tick to the Enter exec pin.
One more thing, you should realize that framerates may be different at any given time. So if you want to build your event/animation upon the framerate, you should think twice.

avatar image HydroWin Dec 14 '18 at 03:17 AM

Ohhhh I see, thanks for the detailed description. I have something that seems to work now from @jayice wise words. Can you elaborate a little on the building event/animation on the framerate? I think what will eventually happen is I will place a delay node in the place of animation that will be timed on frames and when the time comes, add a sequence to have both animation and delay run at the same time or something like that.

avatar image Tuerer Dec 14 '18 at 07:23 AM

I meant that frame rate can change drastically depending on various circumstances. If I just launch a game in the editor, I get 200 fps, but if I drag one blueprint window to the second display, fps drops to 100-120. If I launch a standalone game I may get 400-500 fps. And that's the same computer.
Now imagine people launching your projects on computers with different performance; some will have 120 fps, some 30.
So if you base your animation on the framerate, sometimes it may be over in two seconds, sometimes in eight. I don't think that's what you would want.

avatar image HydroWin Dec 14 '18 at 02:17 PM

Ok I see what you mean now, yes that is something I realllllllllly don't want. But the thing is, I went into the general settings and used the fixed frame rate, I'm guessing that doesn't help with your scenarios? Your answering a lot of my questions and more just keep coming up in my head lol. Is there a way for me to give you points for giving insight? I wish there was a discussion on this somewhere, I can't find one.

avatar image Tuerer Dec 14 '18 at 02:20 PM

Fixed frame rate works if your machine can do more than the fixed number. If it can't, fps will still be lower, and that can disrupt the flow.

avatar image HydroWin Dec 14 '18 at 08:34 PM

Ahhh! Thank you, thanks makes sense! I'm guessing that's why some gaming companies "suggest" better performing PCs? This throw a wrench in the blueprint but how does one keep the frame rate static for everyone without punishing the users with better performing PCs? It's like I'd have to make an entirely separate blueprint in case the person playing isn't at or above 60fps. Sorry for continuing to bring more up, this should really be a forum.

avatar image Tuerer Dec 14 '18 at 10:19 PM

Consider using something else as a base. Timers, Timelines, Skeletal mesh animations, etc.

avatar image HydroWin Dec 16 '18 at 01:09 AM

I see, I see. Rather than relying on the PCs hardware, I should focus on using something more concrete like the PCs clock? Thank you for your knowledge! I will use this to propel myself forward!

avatar image aNorthStar Dec 17 '18 at 12:45 AM

just to mention that, depending on what you are aiming to achieve... there is very likely to be a way to notify the end of your event, rather than trying to time the length of your event exactly... this would be much easier, performance efficient and framerate independent

avatar image HydroWin Dec 17 '18 at 03:11 PM

I know what you mean, unfortunately it's not always going to be at the end of the event. Sometimes before and after delay nodes.

avatar image jayice Dec 17 '18 at 04:18 PM

Much easier, that's very debatable, given the fact that things change during software development. In terms of another event having better performance, while that is a easy statement to make, it's difficult to prove. For if one is concerned about performance, than any call outside of the blueporint VM to the UE4 engine should be avoided. Those calls going to and returning from the UE4 engine, are one of the highest costs of using blueprints. If ya don't believe me, look at the size of the call stack, when calling from the blueprint, to the engine. It's enormous. There use to be a video around here, about blueprints, by one of the developers, and he stated as well, the Call and Return from the VM to the Engine, was expensive, and it is. In terms of being framerate independent, you only need to know the number of frames that have transpired, and the amount of time that has elapsed, and you are immediately framerate independent.

Finally, you have been learning quite a bit, as you have went along, and that has tremendous value.

(comments are locked)
10|2000 characters needed characters left
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