Change Near Clip Plane In Game
I had an idea for the graphical implementation of scopes in a fps game and wanted to test it today, but I forgot that camera components in UE4 don't have a near clip plane distance attribute. I know that you can set the near clip value in the config, but I need to change it in game. Ideally that could be solved by adding a NearClipPlane variable to cameras (which a staff member wrote Epic would be considering), however I would also be happy with a workaround.
asked Sep 20 '15 at 11:27 AM in C++ Programming
You can actually change that value at runtime and see the new clipping parameters take effect. If you wanted to, you could potentially save a float for as many near clip values as you want and change any of the values during an event or in a tick. Then use the console command "r.SetNearClipPlane" to apply it to your active camera (and all other cameras you switch to until you revert the Near Clip back). If you're using blueprints then you can use the "ExecuteConsoleCommand" node to automate the process for you.
I'm not entirely sure how slow it is to be calling a console command every frame, but certainly it isn't recommended. If you're concerned about speed then you can probably find the internal functions being called and avoid the console completely. To be honest though, I use the ExecuteConsoleCommand node a lot and have used it for this exact purpose =P
answered Oct 01 '15 at 11:47 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here