Character Movement Component is Causing Bad Performance

Hey everyone,

I’ve been working really hard to optimize my game, learning all I can about how to do it. I learned how to use the profiler and the stat unit command. My performance is taking a hit, and I figured out that it is because of the game thread, specifically because of character movement components (see images below). This only happens on the main map. I went into the third person template map and this problem did not occur. I obviously can’t delete the character movement components, so what should I do?

Stat Unit Data

Hey there @dudebat923! How many characters are running? How many are executing their actions constantly?

Oh sorry, that is important. Just 2. The player character and the enemy AI.

That’s what it looked like and that just confused me more. Your player character is pulling 8ms game time. If it’s much less in a smaller map, it’s entirely possible your map navigation is massive and it’s checking for pathfinding frequently. How are the numbers in an empty smaller map with both characters running?

After reading your comment, I tried deleting the NavMeshBoundsVolume. It didn’t change anything, plus I can’t really delete it anyway. Here are the numbers for an empty map:

Screenshot (64)

The character movement component is putting out at minimum 7ms less frame time just because it’s in a smaller map? The overlaps on the capsule would produce something on tick, but it’s usually not such a shift so I doubt that’s it. There’s nothing else accessing that player’s movement component constantly?

That’s the weird thing — no. The only thing I’ve done to the movement component is add a function that changes walk speed (for sprinting). That is only called one time, specifically when the player first presses the sprint button or lets go of the sprint button (or runs out of stamina), so that can’t be it, can it? Otherwise, I haven’t touched the movement component. and the sprint functionality still exists on the small map too, so that wouldn’t make sense anyway.

In my tests I had a small jump in frame time but it was only 1ms for a scene of high complexity. I’m not sure why there’s a significant jump if the same logic is being run. I’ve got to do a bit more research on this matter specifically. Keeping total under 16.67ms should keep you in the 55-60fps range still in this case so it should be at least viable for now. May I also know your specs?

Ryzen 5900x
GeForce RTX 3800
32 RAM

I don’t know if this is helps, but I just tried deleting the landscape and spawning in a little cube to walk on. 120 fps. So the landscape may be the problem? If so, how can I make it more performant. I need the whole thing to be loaded the whole time, but it’s not very big (430m X 380m).

Also, I found a useful console command (stat character). This is what it showed me:

Sorry if I’m spamming now. I’m just starting to find some useful stuff.

Oh no don’t worry, more information is always good! If it’s shortly after a post you can add it as an edit in the future (so it stays inside the Bumping rules) and no worries.

It’s looking like we were on the money initially that the character controller is needing more frame time due to the environment, but it seems that the landscape may be at fault. I’ll have to take a look at the character source to see why it’s requiring so much time for landscapes. What kind of resolution do you have for your landscape?

The image below shows the information in the details pane.

That’s significantly smaller and less resolution than I was expecting. I’m going to have to do a bit of testing on this a bit. I already knew landscapes aren’t the most performant aspect, but I didn’t think it would shine through inside of the character component.

2 Likes

Have you found anything? I’m running out of ideas to try and fix it.

Unfortunately not, it looks like the performance hit is common, but not quite as large as the one you’re receiving. Not entirely sure why my larger landscape and standard character don’t cause the same levels. I figured it had something to do with hardware but your hardware is pretty good.

Is there anything I can do?

I’m going to do a bit of research into the character class source to see exactly what it’s doing there, which may give me a bit of insight into why you’re losing 60fps from just the character class alone.

Edit: Couldn’t find too much in this case, only confirmed what we knew that the landscape causes it.

2 Likes

So… I guess I’m just screwed then :upside_down_face:

@SupportiveEntity I figured something out. Maybe it’s useful. The landscape worked well without all the trees (game takes place in a forest). Could the trees be causing navigation issues?