Flashlight for 3rd Person

Blitz3D Forums/Blitz3D Beginners Area/Flashlight for 3rd Person

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How about creating a pivot, then hanging a cone on it such that the pointed vertex tip of the cone is at the pivot and the base is away from the pivot; then, add a light at the pivot pointing toward the cone. Use alpha on the cone so that it's mostly transparent, and DON'T set the cone for collisions. That way, the light is shining down along the axis of the cone and throughout the cone. Maybe you could play with the range/distance on the light, and also maybe use fogging on its range, to make sure the flashlight doesn't illuminate too far, and that it gets diffused as it shines away from the flashlight. Could maybe that work?

Also, set AmbientLight to 0,0,0, to make the scenery dark so that the flashlight can be seen to do its work without being overruled by ambient light.
Here's some code I use in a dungeon crawler game I'm working on. It's not directly a flashlight effect, but I set the light at the pcam (camera at player's position, simulating the player carrying a light source with him as he walks around the dungeon corridors).

;camera stuff
CameraFogMode camera,1
Const fogrange# = 30
CameraFogRange camera,1,fogrange

;light stuff
AmbientLight 0,0,0 ;dungeon to be dark, except for torch (local) lighting
light=CreateLight(2,pcam)
LightRange light,5