x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Change Near Clip Plane In Game

Hello,

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.

Thank you!

Product Version: UE 4.9
Tags:
more ▼

asked Sep 20 '15 at 11:27 AM in C++ Programming

avatar image

Fluppi393
457 36 33 54

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Oct 01 '15 at 11:47 PM

avatar image

PhilipRamirez
96 2 10 19

avatar image Fluppi393 Oct 02 '15 at 09:36 PM

Thank you PhilipRamirez!

I searched the source for the consolde comand in the source code and found out that it changes the global "GNearClippingPlane" float value. I don't think you can modify this value in Blueprints, but in C++ you can simply change it to whatever you want in runtime and it will work.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question