Moving FX Lights
Moderator: Core Staff
Moving FX Lights
Hello
Is there any Tutorials out there for Moving FX Lights?
Thanks
Is there any Tutorials out there for Moving FX Lights?
Thanks
-
- Core Staff
- Posts: 2214
- Joined: February 6th, 2006, 3:18 pm
- Location: Germany/Bayern
Re: Moving FX Lights
moving your FX shouldn't be that hard, only creating your light in effectsed could take some time
THAT HANDS WERE NOT TRACED!
visit my blog: Link
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality
Re: Moving FX Lights
Hark! What is that in the sky? Is it a bird, a plane? No! It's NM coming to save the day!
Moving lights isn't that hard in theory, all it takes is a moving effect that will play a light effect, which can be custom.
So first, with the mapping.
Very simple if you know how to create your typical entities.
In this case, all you have to do is spawn a script_origin by right clicking on the 2d grid and selecting script then origin.
Now you want to give it values, you can use the example below, but I highly advise putting your map name in front to avoid conflicting.
Key: targetname
Value: fxOrigin
That's all it takes for the mapping part.
Now on to the scripting.
First off, you will need to make a brand new effect, and lucky you, I have a light emiting effect here just for you!
Now I'm going to assume you know how to make a pk3 file, so beside your maps, mp, and levelshots folder, you will want to make another folder called fx. In this folder, you can put an extra folder with your map name to avoid conflicting.
I went ahead and put another folder called myFxFolder inside the fx folder.
Now make a txt file in this folder, and paste the following.
This is the code to give off a light effect, you can modify the variables to your liking to fit your needs.
Now when saving the file, make sure that it is saved as an efx file. I called this file myLight.efx
Now for the actual map scripting.
I'm going to assume you know the basics of how to script for a map, such as making a gsc file and how to code simple movements.
So here, we want to both play an effect and make it move, so I will be running two threads in parallel.
That's about it. Now of course, if you have any questions, just ask, I'll explain a little more in detail if you don't understand.
Feel free to modify it however you want.
Moving lights isn't that hard in theory, all it takes is a moving effect that will play a light effect, which can be custom.
So first, with the mapping.
Very simple if you know how to create your typical entities.
In this case, all you have to do is spawn a script_origin by right clicking on the 2d grid and selecting script then origin.
Now you want to give it values, you can use the example below, but I highly advise putting your map name in front to avoid conflicting.
Key: targetname
Value: fxOrigin
That's all it takes for the mapping part.
Now on to the scripting.
First off, you will need to make a brand new effect, and lucky you, I have a light emiting effect here just for you!
Now I'm going to assume you know how to make a pk3 file, so beside your maps, mp, and levelshots folder, you will want to make another folder called fx. In this folder, you can put an extra folder with your map name to avoid conflicting.
I went ahead and put another folder called myFxFolder inside the fx folder.
Now make a txt file in this folder, and paste the following.
Code: Select all
Light
{
life 1000 //Length of time the light is on in milliseconds, 1000 = 1 second
rgb //Color of the light can be changed here, with Red Green Blue (2.55 2.55 2.55 = White)
{
start 2.55 2.55 2.55 //Color of the light at the beginning of its life
end 2.55 2.55 2.55 //Color of the light at the end of its life
flags linear
}
size
{
start 250 //Intensity of the light at the beginning of its life
end 250 //Intensity of the light at the end of its life
flags linear
}
}
Now when saving the file, make sure that it is saved as an efx file. I called this file myLight.efx
Now for the actual map scripting.
I'm going to assume you know the basics of how to script for a map, such as making a gsc file and how to code simple movements.
So here, we want to both play an effect and make it move, so I will be running two threads in parallel.
Code: Select all
main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
level._effect["light"] = loadfx ("fx/myFxFolder/myLight.efx"); //Load myLight effect from myFxFolder
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
lightOrigin thread lightsMove(); //Run moving light thread while sending assigned lightOrigin
}
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
while(1){
self moveX (64,1,0.5,0.5);
self waittill ("movedone");
self moveX (-64,1,0.5,0.5);
self waittill ("movedone");
}
}
Feel free to modify it however you want.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
-
- Core Staff
- Posts: 2030
- Joined: July 24th, 2006, 11:21 am
- Location: Cramped in a small cubicle/making another jump map
Re: Moving FX Lights
Wow awesome tut nm, do you think this will work in cod2 aswell?
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
Re: Moving FX Lights
Thanks for the Tutorial
Instead of lights , there is flames
Instead of lights , there is flames
Re: Moving FX Lights
I don't see why it shouldn'tRez|l wrote:Wow awesome tut nm, do you think this will work in cod2 aswell?
Are you sure? What kind of flames is it?Scorpion wrote:Thanks for the Tutorial
Instead of lights , there is flames
The reason I am asking is because if the flames go very high into the sky, then that is the error.efx playing.
This effect usually plays when it cannot find the efx file you are refering to, so make sure to double check the path and file name.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Moving FX Lights
And make sure you simply haven't copied and pasted NM's script (which we all know, you have).
You need to change the FX file location in both script and folder.
You need to change the FX file location in both script and folder.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Re: Moving FX Lights
Hi , Finally Works (I was using the compile MP folder and it didnt like it, so i placed into a pk3 and it worked )
Iv tried to add a trigger to it
The light shows up but it doesnt move up or down with the trigger or without the trigger.
Any ideas?
Thanks
Iv tried to add a trigger to it
Code: Select all
main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
trigger = getent ("lighttrigger","targetname");
level._effect["light"] = loadfx ("fx/light/light.efx"); //Load myLight effect from myFxFolder
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
lightOrigin thread lightsMove(); //Run moving light thread while sending assigned lightOrigin
}
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
while(1)
{
trigger waittill ("trigger");
wait(1);
lightOrigin moveZ (-1000,1,0.5,0.5);
lightOrigin waittill ("movedone");
wait(10);
lightOrigin moveZ (1000,1,0.5,0.5);
lightOrigin waittill ("movedone");
}
}
The light shows up but it doesnt move up or down with the trigger or without the trigger.
Any ideas?
Thanks
-
- Core Staff
- Posts: 2214
- Joined: February 6th, 2006, 3:18 pm
- Location: Germany/Bayern
Re: Moving FX Lights
main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
trigger = getent ("lighttrigger","targetname");
level._effect["light"] = loadfx ("fx/light/light.efx"); //Load myLight effect from myFxFolder
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
lightOrigin thread lightsMove(); //Run moving light thread while sending assigned lightOrigin
}
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
while(1)
{
trigger waittill ("trigger");
wait(1);
self moveZ (-1000,1,0.5,0.5);
self waittill ("movedone");
wait(10);
self moveZ (1000,1,0.5,0.5);
self waittill ("movedone");
}
}
THAT HANDS WERE NOT TRACED!
visit my blog: Link
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality
Re: Moving FX Lights
Hi
Doesnt work
The light shows but doesnt go up / down.
Iv checked the names etc and there right
I took out the trgger part of it and it still doesnt work
Any idea?
Thanks
Doesnt work
The light shows but doesnt go up / down.
Iv checked the names etc and there right
I took out the trgger part of it and it still doesnt work
Any idea?
Thanks
Re: Moving FX Lights
Obvious problem is very obvious, you are defining what trigger is all the way in the main, but for the game, by the time it gets to that thread, it has forgotten about it. (Lev made the same mistake. )Scorpion wrote:Hi , Finally Works (I was using the compile MP folder and it didnt like it, so i placed into a pk3 and it worked )
Iv tried to add a trigger to it
CODE
The light shows up but it doesnt move up or down with the trigger or without the trigger.
Any ideas?
Thanks
Two solutions, make trigger a level wide variable or define it in the movement thread.
I chose the later for simplicity.
Code: Select all
main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
level._effect["light"] = loadfx ("fx/light/light.efx"); //Load myLight effect from myFxFolder
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
lightOrigin thread lightsMove(); //Run moving light thread while sending assigned lightOrigin
}
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
while(1)
{
trigger = getent ("lighttrigger","targetname");
trigger waittill ("trigger");
wait(1);
self moveZ (-1000,1,0.5,0.5);
self waittill ("movedone");
wait(10);
self moveZ (1000,1,0.5,0.5);
self waittill ("movedone");
}
}
Code: Select all
main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
level._effect["light"] = loadfx ("fx/light/light.efx"); //Load myLight effect from myFxFolder
lightOrigin thread lightsMove(); //Run moving light thread while sending assigned lightOrigin
}
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
while(1)
{
trigger = getent ("lighttrigger","targetname");
trigger waittill ("trigger");
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
wait(1);
self moveZ (-1000,1,0.5,0.5);
self waittill ("movedone");
wait(10);
self moveZ (1000,1,0.5,0.5);
self waittill ("movedone");
}
}
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
-
- Core Staff
- Posts: 2214
- Joined: February 6th, 2006, 3:18 pm
- Location: Germany/Bayern
Re: Moving FX Lights
oopsy, was reading to fast -.-
yep no trigger was defined
yep no trigger was defined
THAT HANDS WERE NOT TRACED!
visit my blog: Link
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Moving FX Lights
small modification to the above...
Firstly, remember this is an INFINITE LOOP, why would you want the engine to find the entity more than once if it isn't changing? Keep it outside the loop.
Secondly, Loops inside loops = infinite amounts of infinite loops.
Every time the loop went round, it created a NEW fx to play, after 1 minute passing you would have 6, eventually stacking to the point where your FPS would be shot and the server would crash.
Code: Select all
lightsMove(){ //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
trigger = getent ("lighttrigger","targetname");
maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
while(1)
{
trigger waittill ("trigger");
wait(1);
self moveZ (-1000,1,0.5,0.5);
self waittill ("movedone");
wait(10);
self moveZ (1000,1,0.5,0.5);
self waittill ("movedone");
}
}
Secondly, Loops inside loops = infinite amounts of infinite loops.
Every time the loop went round, it created a NEW fx to play, after 1 minute passing you would have 6, eventually stacking to the point where your FPS would be shot and the server would crash.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Re: Moving FX Lights
Hello
The light still shows up but it doesnt move.
Any Ideas?
Thanks
The light still shows up but it doesnt move.
Any Ideas?
Thanks
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Moving FX Lights
Are you definitely using a script_origin?
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Who is online
Users browsing this forum: No registered users and 34 guests