Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Dynamic Shadow. I need help.  (Read 2715 times)

0 Members and 1 Guest are viewing this topic.

bfg100

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 5
    • View Profile
Dynamic Shadow. I need help.
« 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.
Logged

Django

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
Re: Dynamic Shadow. I need help.
« Reply #1 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");



Logged

bfg100

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 5
    • View Profile
Re: Dynamic Shadow. I need help.
« Reply #2 on: April 07, 2012, 08:36:16 AM »

@Django
Now it works perfectly! Thanks for help.
Logged
 

Page created in 0.021 seconds with 19 queries.