Download

FPS laggin drastically from 60 FPS to 7 FPS because of my Blueperint???

In this video around 6:20 you can clearly see the lag. I tried to show you all of my Blueprint setup as well as the Error Log plus I go through and try to remove the Error causing nodes and nothing helps. Can someone give some guidance on this please? Would the Construction Script cause something like this? I created a Dynamic Material Instance which as you can see is called in the Error but as you can see I also disconnect it and the lag still persists. Any ideas about what I can do to fix this?

A few things to try…
Clear your message log. It will continue to show messages from past runs and its sometimes hard to see what is new and what is old.
Try leaving your source material selector blank in the constructor and verify that the material you want from your mesh has the same index as the CreateDynamicMaterialInstance node.

Check out the CPU profiler under Window->Session Frontend… It’s not very friendly, but once you figure out out you can get a lot of information on what is taking up CPU time in your game.

The basic usage is to select an instance(probably only one named after your computer hostname), then select the profiler tab and click the datapreview and, if you want to watch a live update, also the live preview buttons.

Scroll through the list of engine/editor systems that should populate the list to the lower left. The interesting options are probably under Game and Physics. For Game you will want to look for something like blueprint time, tick time etc. Under Physics, you will probably only want Total Time. There are lot so maybe only select a couple of them at a time so you can keep track. With live preview off you can scroll through the session and highlight areas to see how much time a system was taking up.

Once you have the settings you want start the game and watch the pretty graph until you game starts to lag. Identify any system that starts to take up more time, memory etc…

cc33266e3c57603dbc7073e7114af5cd007fdfb7.png

Almost forgot, this is my dynamic material setup… very close to your own, but as I mentioned, check the index is correct on the material and also I don’t think you need to specify your material in the asset dropdown.

9229b21c7b901f3a88a27aee702e4cc82236aca0.png

83e656e81ba35e2174120c25ecdff3b2656869d4.png

Hello James0X0A,

I tried the Frontend and you are right…it is going to take some getting used to…however…after running a Automation Test I received 1 failed blueprint and this is the log I am attaching. I also received the FPS lag again and this time thanks to you I have a log. Can you have a look at these and see if you can make heads of tails of the problem?

Thanks for your help!

I’m still getting the feeling that you have an uninitialized material array in your Conveyor Belt or the engine is failing to find the correct material. Check the mesh component in the components tab to see if it has a material at Index 0. I don’t know that it would cause your lag problem though. I would guess maybe something isn’t being properly destroyed and is accumulating in the scene.

Try enabling collisions, or bounding boxes. Start the game and in the console(usually accent ` ]). Type Show BOUNDS or Show COLLISION. Keep experimenting with the profiler

For reference here is where you find your Material index. It is visible on bottom left. There should be at least 1 element in it even if it is blank so there is a place to store the dynamic material.

dc88ca72b7fe2c93f04d044cdac6cf36d61459ae.png

I tried everything you suggested James0x0A and nothing worked :frowning:

This is the Blueprint… broke it up into sections and the Construction Script is where the Error Log sends me every time.

eb19ce70587f885b1c480ae7bb3e7bca7da7571b.jpeg


d899e8637b7c250a464e5c7bfd4ab6c2c96d8ba7.jpeg

This is the video that shows the error occur.

i found using construction scripts caused a massive performance hit…not sure if this is your problem but its worth looking into…i found that if i performed those same operations out of the construction script i got much better performance

I am about to attempt that now. Thanks WarpSpasm! I was under the impression that I had to use the construction script to generate the Dynamic Material Instance since that’s the way it’s shown in all the tutorials.

I tried it and instead of referencing the Dynamic Material Instance this time (which I just opted not to create at all)…The FPS dropped to single digits and the Error log read this:

I actually went through and recreated the entire blueprint from scratch for this test…and it still lagged and sent me to the Construction Script! Is there a way to just get rid of the Construction Script if it isn’t needed?

You can do it either way.

The reason you use constructions scripts is because UE4 does them before gameplay even starts. IE it will execute them in the editor itself, and you can use them to procedurally build things for the level.

If it’s being spawned during the game there is little benefit apart from keeping things tidier

In the control speed section you call destroy actor component, but you never remove anything from the conveyor array. That’s a null reference and your loop time keeps getting longer to iterate over all the invalid movers.

Edit: Note, you shouldn’t modify the array inside the for-each loop, so you will either have to remove elements as a separate step or avoid destroying the components entirely. The second option is probably the most efficent, loop each component to the start of the conveyor when it hits the end. Initialize the array with your movers when you begin play or in the constructor to avoid extra logic in the mover loop.

Edit2: Below are some options to simplify your if-else chain. I like enums because they are labeled and typed, but integers work just as well in this case. Enums are great when you need to enumerate a values that don’t really make sense to define as integers, ie Enum Colors { Red, Blue, Gree, Yellow }. Also they can only be compared to another value of the same type unless you cast to byte. ( Colors::Red == 0 ) is not possible.

Hello Rodstone,
Did you actually see the error log though? Even with me not using the construction script at all I’m still getting the lag and referred to the construction script. Do you know if it is possible to generate a dynamic material instance from inside the Event Graph? I created one but it didn’t function “at all” like the one I created in the construction script in my previous Blueprints. I use them in order to animate a Param in my material.

Thanks James0x0A I will give these a shot. I hadn’t thought of this yet. Thanks again! Oh BTW…is there anyway you can send me the image you have here? I tried to double click and expand it so I can see it better but it isn’t expanding.

From the glances over your Blueprint it looks like you haven’t given the master material for creating your dynamic one from, when you create it. Maybe you have solved that problem already though?

Also I notice a large int == true false thing… Could you do that with a switch on int?

Image
The image just shows a couple of switch types, as rodstone suggested switch on int and also switch on enum.

I hope the other stuff I suggested does help with your performance problems.

Hey James0x0A and or Rodstone…would placing a Collect Garbage node anywhere in the sequence help with removing the null references? I am trying it on the ForEachLoop Completed pin but am not sure if that is the best or even the correct place to do the job. Any thoughts?

3989bbd9b6f2e39fb8e217fd02a74d3eadd54fdd.jpeg

CollectGarbage would destroy any object that was no longer referenced, but you reference it in the array. If you want to try a different solution to the ones I suggested earlier, you can iterate in reverse over the list and remove each element from the end of the array. That avoids the problem of changing the size of the array because the next element stays in place.

Here is an example of the ReverseForEachLoop… It’s almost identical to the normal ForEachLoop except you have to start with Array.Length - 1 and decrement to 0.

&stc=1&d=1413781570

Hi. :slight_smile:

Firstly you want to actually set “CB Dyn Anim Mat” to something other than “Null”. Every tick your trying to set the value in a “Null” material to so something. This is pretty much why your getting the error messages in the log. Give it a value and they’ll go away.

Also setting the value of a material every tick is a little inefficient, especially if the value isn’t actually changing. I would advise making this it’s own remote event that can be fired when you actually change the values you wish to control speed of the material. (As a note you will actually need to set the material of the mesh to the dynamic material for it to work. :slight_smile: )

One other thing I would advise you change is the “SpawnMover” function/event. You currently have it spawning off a tick which I personally wouldn’t advise. Instead you should have it fire whenever one of your conveyor boxes gets destroyed. This will also make the setup more robust when you start changing the speed of the conveyor meaning you don’t need to worry about more spawning in than are getting destroyed.

I hope this helps.

Thanks james0x0A,

I will give this setup a try. I did take your advice on changing the switch on Int btw. It worked nicely…still getting the error messages but the setup is cleaner in that part of the BP anyway. Thanks again!