How can I achive something like this in ue5? https://youtu.be/SA-6_0tdkjQ
Something like this is definitely doable in UE, though fps is going to be dictated by the cpu and gpu capabilities of the machine running it. For best results though, minimalize actor ticks, use soft reference variables wherever possible and keep your poly count and texture size as minimal as possible
This is the answer I want, but I need a more detailed explanation. I am relatively new to coding, so I need a little guidance on how the coding process will go.
I know I shouldn’t use Navmesh, and I observed that collision logic will eat up a lot of fps in a situation like pathfinding. So I’m not sure how I should proceed. When I find the desired location with mathematical methods and give the order to move there, they will pass directly through the walls. How can I prevent this?
From what I read on the forums, using references reduces fps a lot, so I don’t know how I should use that method.
If you have an idea about the process, I would be very happy if you could give a short example!
Hi, 500 units in 8.3ms could work with the build-in pawn (character is likely a bit too heavy, I did a quick test a short time ago, see my second post here: [SOLVED] 2D Game - Many AIs, performance issues with Character Movement Component. - #3 by Appear ). So you could create a new pawn blueprint, add a capsule component as root (to use the build-in pathfinding and ai movement) and potentially also add your skeletal mesh (first try without it tough, just using some sphere mesh to see performance).
What would be important:
- Remove all collision (disable collision in your capsule component and in whatever you add on top, if you have a skeletal mesh remove the physics assets)
- Have as less scene components as possible (each additional scene component costs you a bit for the movement, since it needs to be updated on tick)
- Handling animation cost if you use skeletal meshes. You can use animation sharing Animation Sharing Plugin in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community (was also stated in the video you have shown above), cause otherwise if you have 500 meshes, each of them ticks their own animation (which is unnecessary in that case) whereas with the animation sharing you could set it to N (e.g. 3 or so, they will share those N individual animations).
At first you could try without animation sharing (since it takes a bit time to setup) and use update rate optimization and only tick when in view instead Animation Optimization in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community - If you want your bots to avoid each other (not constantly run through each other) you could use RVO avoidance (that will cost you a bit, but is relatively cheap), you can enable it by a checkbox in the movement component if I remember correctly Using Avoidance With the Navigation System in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community
- And use as less materials as possible in your skeletal mesh (ideally only use 1). Cause each skeletal mesh and material costs you two (I think?) drawcalls, if you enable shadows on the meshes then at least one more. So 500 meshes with a single material would be 1000 drawcalls which should still work, but if you would have like 10 materials on the mesh, then the amount of drawcalls will likely cripple performance. This point affects the GPU, all the other points above affect the CPU.
When I find the desired location with mathematical methods and give the order to move there, they will pass directly through the walls. How can I prevent this?
You can use navmesh and the build-in pathfinding, that should not be an issue (and would solve your problem of running through walls). If you want to implement your own movement (I would suggest to try the pawn approach first, also to have a baseline if it turns out to be too slow), you could still use a navmesh and build-in pathfinding, get the path to the target location (don’t remember the function for that, but used a while ago) which will output you a list of points from your current location to the target location. Then you could sequentially move to all points of the list.
The approach above allows you to control each individual unit. If you want an even larger crowd, then you could switch over to doing everything on the GPU and use a niagara system to simulate the crowd (never done that, so no idea how that would work exactly). That also removes the drawcalls bottleneck, since static meshes can be instanced. Here is a video from epic on simulating large crowds: https://www.youtube.com/watch?v=CqXKSyAPWZY using niagara or you could also google for something like “ue5 niagara swarm”. There you cannot have animations, but would need to bake them out to textures (there is an anim to texture plugin, never used it though) and then drive the animation in the material through WPO (vertex animation).
I would recommend using a navmesh, it’ll make things way easier and beyond AI movement it has uses. I’m making a Diablo style RPG and I use it in some AOE attacks for example. An AI controller can handle controlling large quantities of NPC like this if you set it up right. I have a classe that controls various enemy types in my game that behaves like this. I don’t spawn 500 at once as my environments and other assets are not optimized for that kind of thing, and it’s just not that kind of game, at most ill have maybe 20-30 bots rushing the player. But maybe I’ll give it a shot and let you know the results
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.