Blabberbox » 42 » Unreal Engine 4 NotesShare on Twitter

Unreal Engine 4 Notes

May 16th, 2020 | Posted by pftq in 42 | #
General notes and things I wish I knew as I delved deeper into #UE4:
- Package build by default includes unused assets, which can bloat the size of your game.  Go to Project Settings -> Packaging -> List of Maps to package only assets referenced by that map.  To be more aggressive and reduce unused assets in general (or to keep smaller backups), right-click your map and Migrate to a new project to create a new folder with only the assets used in your game.  More tips on this here.  But don't mark your game as shipping or distribution until you want to disable loading of listening servers by command line / shortcut.
- Do not use numbers in the project folder name.  Otherwise builds will fail to run.
- Do not use Duplicate, as it moves the object slightly.  Use copy+paste.
- Never use AND boolean functions.  They will calculate every condition even if the first one is already false.  Use multiple branch nodes instead.  See Blueprint Scripting Has No Short-Circuit Evaluation.
- Never rename asset files en mass.  50/50 chance the project gets corrupted and starts failing to build or package somewhere.
- Windows MR crashes Unreal Editor and games when it sleeps.  Edit registry or nudge it every few minutes.
- Use Local and Assign variables for temporary variables that get erased outside the function or macro.
- CustomEvents are asynchronous and avoid holding up the CPU.  Functions and macros are not the same way.
- Minimize use of functions instead of macros because functions create a callstack, which adds up in performance overhead, whereas macros run as if you just had the nodes at the top level.
- Disable motion-blur under post-processing in both the FirstPersonCamera and the post-processing volume object in the level.
- isHMDenabled requires a delay of 1 frame from BeginPlay event (node with delay of 0 sec works).
- Removed splitscreen players will still play audio.  Workaround is to teleport them to one of the remaining players before removing and add a delay of a split second before calling Remove Player.
- In Particle Systems, In value means time and out value means the value at that time.
- Use LODMethod ActivateAutomatic for particle systems to not jump in size as you get closer or farther.  Useful for things like bullet trails that don't last long enough for you to notice if it's a bit bigger or smaller than it should be (vs jumping in size if LOD changes).
- Cable component tick group must be post-physics (set with Blueprints). Otherwise at high velocities, the attachments are visually jittery and jump around a lot.  Similar with many other particles-based things like ribbon trails.
- Ribbon trails are still unstable no matter what tick group at high velocities.  Try checking Tangent Recalculation under Ribbon data, which sometimes helps snap it into the right place.
- Ribbon emitters don't work in higher LOD levels.  Don't bother.  Create multiple particle systems with draw distance ranges instead.
- Ribbon particles cost a lot of CPU.  Use sparingly.
- Projectiles can inherit velocity by adding the velocity of the parent, but particle systems at high speeds for some reason over-apply this. If possible, set the particle system to Use Local Space and apply fake initial velocity instead, as that works much more smoothly but you risk the particle system looking off if your initial velocity is too high or low vs what the emitter is actually moving at world space.
- Use Branch + isServer to run things only on the server (like impulse and collisions), not SwitchIfAuthority.
- Keep global variables in GameMode or GameInstance.  Players can then use GetGameMode or GetGameInstance to fetch these variables.  If multiplayer, do all this through the server.
- Replicated actors only update when moved.  If a player joins late, the location will be wrong until something moves it.  So when a new player joins, you want to give every object a nudge to push updates out.
- All actors with "Replicates" checked replicate position/rotation/velocity even if "Replicate Movement" is unchecked (important to know for optimizing bandwidth).  Use Smooth Sync plugin from asset store to be more selective on what gets replicated.
- Character Movement continues to replicate even if "Replicate Movement" unchecked (separate from above "Replicates").  Disable with Blueprints by setting Ignore Client Movement Error Checks to save an easy 10 bytes out of 70 on network overhead for the actor; it is also a source of rubberbanding at high speeds (it even says so in the tooltip).
- Replicated variables are necessary for new players joining to know the status of everything else.
- Create a replicated variable at BeginPlay and a branch with IsLocallyControlled to force server and other players to wait until the owning player has submitted/loaded all information.
- Disable gravity and set gravity scale to zero on non-server players to reduce replication bounciness/jittering.  Causes rubberbanding / distinct stutter every 1-2 sec.
- Limit server tick rate to reduce rubberbanding due to sending too many updates per second to players.  See https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1761890-multiplayer-lag-if-listen-server-goes-beyond-120fps
- Kitbash3D for building collections way higher quality than what you find in the asset store.
- Vector operations in materials are called "components." If you want to break a vector into xyz, use the Split Components for RGB (R=X, G=Y, B=Z).
- Do not use max draw distance on particle systems details tab.  Particles still incur performance hit even if not visible.  Use LODs in the particle emitters editor instead.
- Camera controls and fades are under GetCameraManager.
- Enable HMD is bugged for full-screen and causes things to go off screen if you're using it to disable VR.  The fix is to also make the game windowed mode.  See: https://answers.unrealengine.com/questions/964170/widgets-off-screen-after-disabling-hmd.html?childToView=964174#answer-964174
- How to avoid losing sound in the game when minimized or alt+tabbed to a different window: https://answers.unrealengine.com/questions/66918/keep-audio-from-losing-focus.html
- Visual Studio dependency for C++ and dedicated server building from source requires the MSBuild option when you install VS: https://forums.unrealengine.com/development-discussion/engine-source-github/1659308-generateprojectfiles-error-unable-to-find-a-valid-installation-of-visual-studio
- To scale multiple objects proportionally as a group (not each to their own center), parent them to one object and scale that one object.
- Static lighting requires that you place reflection capture actors in areas of importance; otherwise they end up appearing too dark after baking due to the materials losing the glossiness/reflectiveness.
- Once Steam SDK is included in the game (and not disabled with -nosteam), you can no longer connect via IP, only with Steam Server IDs: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1483622-connect-to-steam-dedicated-server-via-raw-ip
- Copies of the same static mesh are not automatically instanced.  Difference between thousand copies of the same mesh vs instanced static mesh is thousands draw calls vs single digits: https://www.youtube.com/watch?v=oMIbV2rQO4k . Either merge the meshes into one (or use mesh merge culling volume) or convert them to instanced static meshes or use HLODS (automatic grouping into one mesh based on volumes without destructively merging).  Also useful is Mary Nate's Instance Tool to convert between static and instanced meshes easily.
- To bulk edit LODs, select multiple meshes in content browser and choose static mesh > import/add/copy/paste.  This is not in the property matrix.
- Use -nullRHI argument in starting your listen server to disable graphics rendering, cuts CPU/GPU usage by 80% and gives you much of the benefits of a dedicated server w/o going through the source compiling.
- Ctrl+Alt+Click to drag select.
- Ctrl+S only saves the current map, not the blueprints, meshes, or other assets open.
- Middle-click drag in top-down view to measure distance.
- Use Advanced Sessions plugin for Steam online functions, which are available to C++ but not blueprints.
- Host sessions should call Update Sessions once every few minutes to prevent Steam from automatically dropping the host from the sessions list for new players.
- Voice chat is already built-in for UE4 and just needs to be enabled.  No Steam or plugin needed.  See CouchLearn.  All data limits must be increased to 5000000 (million) or more to avoid cutting out on more than 2 players, even though it doesn't actually use that much at least based on Task Manager.  See VOIP Network Saturated.  Also attenuation will not work for players who joined before you and are already speaking; to fix this, you must have a call to mute + unmute (1 sec apart) using AdvancedSessions to trigger the player's voice chat to reset - see VOIP Attenuation Not Working for Join-in-Progress.  A last problem is that your code might not be fast enough even on begin plays, so you still hear everyone for a split second.  A workaround is to set the Voice Audio class to volume zero at the begin plays of the player controller and fade it back in a seconds later - see Start Voice Chat Muted.
- Use Get Player Controller [ 0 ] -> Get Controlled Pawn for the point of view of the current local player (for customizing draw distance to other players, etc).
- Adjusting game volume via Set Sound Mix Class Override is multiplied to the current volume, so if the current volume is zero, volume will not change.
- Steam SDK cannot be updated on the same UE4 version without recompiling UE4 from source.  Do not try to fix what's not broken.
- Actor movement is computationally expensive (takes up CPU per frame).  Attach multiple actors to one to move as a group without incurring cost per actor.
Graphics Optimizations:
- Use console command in blueprint/csharp "r.AllowPointLightCubemapShadows 0" for instant 10 fps gain with little noticable difference.
- Shipping build will give you an instant 10-15 FPS increase, if you're trying to squeeze performance (ie for VR).
- Backup your project before checking Forward Shading, as it'll put you through hours of rebuilding shaders.
- Static light baking on large maps is worse than movable dynamic lights, due to the overhead of loading all the baked lighting.
- VR splash screens will stay displayed into the next game unless you explicitly call hide splash screens.  Best practice to call hide splash screens before your own game.
- VR splash screens require UserInterface2D(RGBA) in texture compression settings to work.
Notes for TrueSky:
- Cloud resolution can be increased at least to 480 without impacting VR frame rate.  No need to be so tight here.
- Altitudes under Sky settings affects whether objects get lit up high in the atmosphere.
- Translucent objects won't be obscured by clouds.
- Lights don't affect clouds.
- Moonlight doesn't affect non-clouds.
- Cosmic background doesn't appear in built game.
Last Updated Sep 1st, 2020 | 181 unique view(s)

Leave a Comment

Name: (Have an account? Login or Register)
Email: (Won't be published)
Website: (Optional)
Comment:
Enter the code from image: