Phantom on 26/1/2018 at 05:50
This is a quick guide for making a camera overlay that you can turn on and off on demand. I am using NewDark 1.25 and NVScript 1.26 to achieve this effect, make sure your Dark version is up to date and that NVScript is loaded into your mission. Skip down to the video to see the end result of this tutorial.
1.
Create a new Meta Property in the object hierarchy, let's call it CamOverlay. Add
Renderer -> Camera Overlay. Edit the properties as follows:
Active: [TRUE]
Bitmap Scale Mode: [Scale to fit screen]
Filter Color: (This can be whatever color you want, I am using 240,5,5 for a red overlay.)
Alpha: (I recommend a value between 10 and 100, depending on how much you want to limit player vision with the overlay on.)
(The rest of the fields are unused for this demo, but you can use them for bitmap overlays, I will reference the instructions at the end of this guide.)
2.
Save your gamesys to ensure the Meta Property remains in the hierarchy.
3.
Create the following items nearby:
One (1)
fnord -> Marker, One (1)
fnord -> TrapTrig -> Inverter, Two (2)
physical -> Gizmo -> Switches -> Buttons -> Button.4.
Edit each Button's properties:
Name one button OverlayOn and the other button OverlayOff for the purpose of this tutorial. You can call them whatever you like for your own tasks.
5.
Edit the Marker's properties:
Change the name of the marker to
OverlayTrap for the purpose of this tutorial.
Add S -> Scripts and set Script 0 to
NVMetaTrap.
Add Editor -> Design Note and add the following text:
NVMetaTrapOn="TurnOn";NVMetaTrapOff="TurnOff";NVMetaTrapMeta="CamOverlay";NVMetaTrapTarget="&ControlDevice" Note that the name in NVMetaTrapMeta must be the exact name you used for your custom Meta Property.
6.
Create the following object links: A. ControlDevice from Button 'OverlayOn' to the Marker 'OverlayTrap'.
B. ControlDevice from Button 'OverlayOff' to the Inverter.
C. ControlDevice from Inverter to Marker 'OverlayTrap'.
D. ControlDevice from Marker 'OverlayTrap' to Garrett. (Note: You must link this to Garrett(-2099), linking to the starting point does not work].
7.
All done! Save your mission and enjoy. This is the result.
(
https://vimeo.com/252829834)
You can also place the buttons in a blue room or anywhere outside the playable area, and trigger them with other events within your mission. For example; a bounds trigger that creates an overlay when the player enters a specific area, etc.
NVMetaTrap is vital for this setup. Essentially you are sending a TurnOn message to the Trap with one button to add the overlay Meta Property, and sending a TurnOff message to the trap via an Inverter with the second button to remove the overlay Meta Property. If not for the custom script it would require S&R's or conversations to achieve the same effect. It's late and I'm past due for bed, hopefully I didn't miss anything, if so I will correct it tomorrow. Cheers taffers!
P.S. Here are the instructions for different ways you can use Renderer -> Camera Overlay:
Code:
New Prop: Renderer->"Camera Overlay"
------------------------------------
The property can be assigned to objects that have, or can have, a camera attached to have a custom camera overlay
rendered while the camera is attached to it. The object could be the player, or for example a scouting orb. If
the "Camera Overlay" is active it will override any default overlay of the game. In other words if a custom overlay
is set on scouting orb, it will be used instead of the default overlay effects for it.
An overlay can either be a color tint on the entire screen, like the coloring when the player is under water, or
a bitmap. For example a black bitmap with two holes "cut out" in the alpha channel to get a viewing-through-
binoculars effect.
The bitmap is loaded from the "BITMAP" dir, like with bitmap particles, except it can either be a single texture
with one image file in "BITMAP" or it can be an animated bitmap with numbered files in "BITMAP\txt" or "txt16".
In order to deal with different display aspect ratios when using a bitmap overlay, there are following scale modes:
"Scale to fit screen" - Bitmap is scaled to cover the entire screen, shapes will look stretched/squished
depending on if viewed on 16:9 or 4:3.
"Fit 4:3, mask w. color" - The bitmap is treated as a 4:3 image (regardless of its actual dimensions) and
is scaled to fit screen while maintaining the 4:3 ratio, the empty areas on the
sides on widescreen displays will be filled using the specified "Mask color".
"Fit 4:3, mask w. edge" - Same as above except that instead of filling the sides with the mask color, it
uses the edge pixels of the bitmap and stretches them outward.
"Crop 16:9, mask w. color" - The bitmap is treated as a 16:9 image, and if the display aspect ratio is
narrower the image will be cropped, down to 4:3 at most (the bitmap should be
created so that it looks ok when cropped to 4:3, but giving 16:9 user a little
extra fluff). In the unlikely event that masking is required, it's done the
same way as "Fit 4:3, mask w. color".
"Crop 16:9, mask w. edge" - Same as above except masking is done like "Fit 4:3, mask w. edge".
If the bitmap object has multiple frames the animation rate is set with "Ani frame time (ms)" as the duration, in
milliseconds, per frame. A value of 0 disables animation.
The "Filter color" is multiplied with the bitmap, so if the bitmap is black it has no effect, if it's white it will
end up using the filter color as is. If no bitmap is used, the filter color is used as the tint color for the entire
screen.
"Alpha" sets the overall transparency, including any masking areas. Setting alpha to 0 will skip overlay drawing
and can be used if you want to disable a native overlay without wasting any rendering time.