AuthorTopic: Flashlight script (Read 17077 times)

This example project demonstrates a flashlight scripting in WME. You can set various parameters of the flashlight in the beginning of flashlight.script (you will find the script in the "flashlight" folder in the project below).

Usage:

1) in your scene, create a dummy region called "foreground" and move it to the very bottom of the node list in SceneEdit2) attach the flashlight.script to your scene

Currently the script displays the light cone at the position of the mouse pointer, if you want to display it at a different position, change the coordinates in the Update() function call in flashlight.script.

You can change the flashlight graphics for example to have a semi transparent edge around the light cone etc.

When I use a 120x120 tile and change the variables accordingly, there's been known to be a grey stripe appearing on the right side of the screen, then fading away. Something related to the refreshing of the tiles perhaps?

When I use a 120x120 tile and change the variables accordingly, there's been known to be a grey stripe appearing on the right side of the screen, then fading away. Something related to the refreshing of the tiles perhaps?

Um, darn. Ok, you can try to change the two occurences of line:for(var i = 0; i<=NumTilesWidth; i=i+1)

This reminds me of Alone in the Dark 4. Ever played it? It features prerendered backgrounds, but the character's flashlight can "light up" the darkened backgrounds. The cool thing is that it also creates shadows based off the flashlight's position, and they react appropriately to the flashlight. Would it be possible, in WME, to make the dynamic shadows react to the light cone?

You'd have to get the 3D coordinates based off the center point of the flashlight cone and trace from the player's world position to this vector in the level. Everything within the circular light cone would need to be influenced, of course.

I'm not sure right off the top of my head how to do this in WME, but what I described above is a start I suppose. There's a PC demo of the game floating around if you want to see the effect first hand. It's not the greatest game, but the effect is nice.

EDIT: Actually, I just played it, and it doesn't cast shadows, so I'm wrong about it. The flashlight is projected onto the walk plane, though and it lights up parts of the background it touches nicely. It looks like a real directx light because of an obvious tessellation effect.

Hmm, you can change the light position for shadow projection in a script, so I think it should be possible to some extent. In combination with the above script or with additive blending it might yield some interesting results.

There are two background pictures for each scene in AITD4: a dark version and a lit version. The light cone is projected on a simplified version of the scene and the resulting image is used as a blend factor between the lit and unlit version. (Well, that's the basic idea but it couldn't work exactly like that on the PS1). The characters and monsters have simple shadows but on the PS1 and on the Dreamcast version they have stencil buffer-type shadows. I don't remember what light source is used for these stencil shadows, though.

But I remember seeing a trailer for this game in early 2000 where the light cone intersects with a pillar in a room and the pillar projects a shadow onto the environment. This was all done in 3DS MAX but rendered with no texture filtering so as to look like PS1 real-time rendering... Maybe that's what confused you

Anyway, the main difference here is that the light cone is projected in 3D, and I don't think that's the case in this flashlight demo, unless I missed something.

I only played it on PS2, and the demo I mentioned above is the PC version. I never saw the PS1 version. I now remember reading an interview talking about the use of two backgrounds. I guess they faked the perceived dynamic shadows on the backgrounds then.

Well on the DC version (which served as a basis for the PS2 and PC versions) the characters' and monsters' shadows are projected to the simplified model for the background. Or maybe on a separate model ? I can't remember, it's been quite a while. But WME is getting close to the techniques that were used in AITD4 now that you can define "shadow" planes in the 3DS collision files and have simplified models for actor shadows.

Sorry I know this post is really old, but I need some help. Im designing sort of a puzzle mini game and I have been using this script. Is there a way to make the flashlight stay transparent on the locations the mouse moves too? For example, if you start the game and move the mouse down, everywhere the mouse touches will stay lit and not go away. I was thinking maybe just making one big black image instead of tiling them, or maybe the tiled entities get deleted when the cursor moves over them. If anyone can help, let me know Many thanks !!