Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: bfg100 on April 06, 2012, 09:23:19 AM

Title: Dynamic Shadow. I need help.
Post by: bfg100 on April 06, 2012, 09:23:19 AM
I would like to get the actor shadow like in the Alpha Polaris for instance, where the shadow changes its position relative to the light source.
I have something like that:
Code: [Select]
var lightpos, lightposX, lightposY,lightposZ;

lightpos = Scene.GetLightPosition("Lamp");

 lightposX = lightpos.X - this.PosX;
 lightposY = lightpos.Y;
 lightposZ = lightpos.Z - this.PosZ;

actor.SetLightPosition(lightposX, lightposY, lightposZ);

What else should I do? Maybe some loop?
Maybe someone could help me with this, please.
Title: Re: Dynamic Shadow. I need help.
Post by: Django on April 07, 2012, 01:31:43 AM
You're on the right track.

I would define that code as an event in the actor.script (call it "lightupdate", e.g.):

Code: [Select]
on "lightupdate"
{
    //Your Code
}


Then you could trigger it like this in the game_loop.script:

Code: [Select]
if(actor.IsWalking()) actor.ApplyEvent("lightupdate");



Title: Re: Dynamic Shadow. I need help.
Post by: bfg100 on April 07, 2012, 08:36:16 AM
@Django
Now it works perfectly! Thanks for help.