Dynamic Light

Posted By: Erick_Castro

Dynamic Light - 08/22/09 03:46

I created an action that make a dynamic light to be on and off in a room.

action luz_random
{
my.lightred = 250;
my.lightgreen = 250;
my.lightblue = 170;
while(1)
{
my.lightrange=200;
sleep(1.5);
my.lightrange=0;
sleep(1.5);
}
}


it works good.
But i see that my gun entity defined in layer 1
is afected for the dynamic light when it is turned ON even when i am in other rooms of my world and separated from walls.

entity gun0
{
type = <el_revolver.mdl>;
ambient = 0;
pan=90;
x= 5;
scale_x=2;
scale_y=2;
scale_z=2;
layer=1;
y= 3;
z= 0;
ammo=0;
numbergun=1;
recargar=1;
}


I dont want that happens , but i dont know why it happens.

Thank you for your help, friends
Posted By: Claus_N

Re: Dynamic Light - 08/22/09 11:57

I'm quite sure that it happens because it's a view entity - it does not exist in world-space, thus walls etc. won't block the light sources/cast shadows on the view entity.

The only things to prevent it that comes to my mind:
- Turn lighting off for the view entity
- Make a normal entity (in world-space) instead
Posted By: 3run

Re: Dynamic Light - 08/22/09 12:31

Claus_N I'm allso using view entity in my game, and I have problem with it. I cannot use shader on it! There is no dynamic light!!! X_x WHAT I HAVE TO DO?
Posted By: Claus_N

Re: Dynamic Light - 08/22/09 21:48

View entities got its limitations. I don't know whether a material can be attached those, but if not, you'll simply just have to use a normal world entity I'm afraid.
Posted By: Erick_Castro

Re: Dynamic Light - 08/22/09 22:03

Claus_N Thanyou for your help.
The entity, or view entity, of my gun i defined the next way:

entity gun0
{
type = <el_revolver.mdl>;
ambient = 0;
pan=90;
x= 5;
scale_x=2;
scale_y=2;
scale_z=2;
layer=1;
y= 3;
z= 0;
ammo=0;
numbergun=1;
recargar=1;
}


How can i define it like a real entity in the world space?
o how can i turn off the lights of the view entity?

thank you friend.



Posted By: Claus_N

Re: Dynamic Light - 08/23/09 09:21

You can do it like this:

Code:
entity* theGun;

function gun_function()
{
	my.passable = on;
	my.ambient = 0;
	vec_scale(my.scale_x,2);
	
	while(my)
	{
		vec_set(my.pan,camera.pan);	// Same angle as camera
		
		vec_set(my.x,camera.x);		// Same position as camera
		
		// play around with these values
		my.x += 5;
		my.y += 0;
		my.z += 0;
		
		wait(1);
	}
}

function createGun()
{
	if(theGun != null) {ent_remove(theGun);}
	
	theGun = ent_create("el_revolver.mdl",camera.x,gun_function);
}



Edit: If you want multiple guns, I suppose it's better to use ent_morph to change the gun model, instead of creating multiple gun entities and switching which one is visible smile
Posted By: Erick_Castro

Re: Dynamic Light - 08/24/09 02:47

Claus_N thank you for your time and your help, friend!
© 2024 lite-C Forums