Modme Forums

Spawn FX when player hits trigger?

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: xikamuix
So im trying to get FX to spawn/play when player hits trigger.

function fx()
{
	FXPlay = GetEnt("fx", "targetname");
	self endon( "death" );	
	while( true )
	{
		self waittill( "trigger", player );
		SpawnFx(level._effect[fx_elec_sparks_int_spire], (-2139.462,-943.440,-188.661));
		break;
	}
}



Is what i tried myself to get it working.


ModmeBot:

Reply By: Yasser143
Is this suppose to be a tutorial or u need help with something?


ModmeBot:

Reply By: Exofile

Yasser143Is this suppose to be a tutorial or u need help with something?


As OP stated, this is what he/she tried him/herself.


ModmeBot:

Reply By: natesmithzombies
This code may not be exactly right because I am at work and cant test but this is will be enough to get you by:



At the top of your .gsc file you need to define the fx. Here is an example:

#define EXAMPLE_FX "fire/fx_name"  // this can be named anything you want and the "" part is the fx location: share>raw>fx>folder_name>fx_name
#precache( fx, EXAMPLE_FX ); 



Then in your script you can do something like this:

trigger = GetEnt( "example_trigger", "targetname" ); 
trigger waittill("trigger", player); 
PlayFx( EXAMPLE_FX, trigger.origin ); 



You also need to add the fx to your mapname.zone file like so:

fx,fire/fx_name





Like I said, its not exactly what you need but it should hopefully help you understand how I do scripted FX


ModmeBot:

Reply By: xikamuix

natesmithzombiesThis code may not be exactly right because I am at work and cant test but this is will be enough to get you by:



At the top of your .gsc file you need to define the fx. Here is an example:

#define EXAMPLE_FX "fire/fx_name"  // this can be named anything you want and the "" part is the fx location: share>raw>fx>folder_name>fx_name
#precache( fx, EXAMPLE_FX ); 





#precache( fx, EXAMPLE_FX ); ---> #precache( "fx", "EXAMPLE_FX" ); ??

Also can i link that fx to play on script struck so i can easily change the position of the fx?

Also the script doesnt even get triggered when i hit the trigger.


ModmeBot:

Reply By: natesmithzombies

xikamuix

Also can i link that fx to play on script struck so i can easily change the position of the fx?


It might be

#precache( "fx", EXAMPLE_FX ); 



but there are definitely no "" on EXAMPLE_FX as it has been defined. In order to play the fx on the strcut you would need to do something like this:

trigger = GetEnt( "trigger_example", "targetname" ); 
trigger waittill("trigger", player); 
spot = struct::get("location_struct", "targetname"); 
PlayFx( EXAMPLE_FX, spot.origin ); 


ModmeBot:

Reply By: xikamuix
I´am not even getting it to trigger...


ModmeBot:

Reply By: natesmithzombies

xikamuixI´am not even getting it to trigger...


Did you run that function?


ModmeBot:

Reply By: xikamuix

natesmithzombies
xikamuixI´am not even getting it to trigger...


Did you run that function


yes.


ModmeBot:

Reply By: natesmithzombies

xikamuix
natesmithzombies
xikamuixI´am not even getting it to trigger...


Did you run that function


yes.


Paste your code here and send me the link