UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

How to make a following light?

broken avatar :(
Created 7 years ago
by Big-Beautiful
0 Members and 1 Guest are viewing this topic.
1,695 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 25 May 2015
Last active: 5 years ago
Posts
31
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
i hate mei
Signature
Must be kept sacred, heavenly eggs
Mustn’t be desecrated with egg bootlegs
×
Big-Beautiful's Groups
Big-Beautiful's Contact & Social Linksfortress-of-branitude
heyo. I'm trying to have a light follow you around but my script isn't working. I've placed a light in radiant with the targetname "light_a" and I've called this function in the main one.

Code Snippet
Plaintext
function light(player)
{
light = GetEnt("targetname","light_a");
light EnableLinkTo(player);
light LinkTo(player);

}
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 6 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
Code Snippet
Plaintext
While true do

light.origin = player.origin + (0, 0, Y)
light.angles = player.angles
Wait(0.1) -- wait might only work with numbers higher then 0.1
End
Last Edit: February 03, 2017, 04:07:09 am by MegaMech43
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 12 months ago
Posts
106
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
Signature
Let he who has not sinned cast the first stone.
×
Archaicvirus's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Archaicvirus's Contact & Social Links
First of all, you're using improper syntax in two of your functions. When you do:
Code Snippet
Plaintext
light = GetEnt("targetname", "light_a");
//This is asswards ^
//Proper way

light = GetEnt("light_a", "targetname");

Then you have this:
Code Snippet
Plaintext
light EnableLinkTo(player);
//This is wrong ^
//EnableLinkTo doesn't take any arguements
//Right way
light EnableLinkTo();
//then
light LinkTo(entity)

I haven't tried using a "radiant light" in script, however you can easily use an "FX light" to accomplish what you need. First of all, open radiant, go to the fx browser, and find a good fx light that you want to use, or create/edit your own. Then in script, when you are ready to spawn the "following light", you need to get the player first. For testing purposes, just drop down a trigger_use, give it a targetname like "fxlight". Then in script, do:
Code Snippet
Plaintext
#precache("fx", "name_of_fx_file");
#namespace FXlightFollower;

function init(){
level._effect["fx_light"] = "name_of_fx_file";
}

function fx_light(){
FXtrig = GetEnt("fxlight", "targetname");
        FXtrig SetCursorHint("HINT_NOICON");
        FXtrig SetHintString("Press &&1 to summon light fx");
FXtrig waittill("trigger", player);

fx_follower = Spawn("script_model", player.origin + (0, 0, 80));
fx_follower SetModel("tag_origin");
PlayFXOnTag(level._effect["fx_light"], fx_follower, "tag_origin");

player.light_follower = fx_follower;
player thread light_follow();
}

function light_follow(){
while(1){
halo = self.origin + (0, 0, 80); //80 units above the player - adjust height as necessary
self.fx_follower MoveTo(halo, .05);
wait(.05);
}
}

//When you're ready to stop the fx, do:
self.fx_follower Delete();

Don't forget to add the fx in your zone file. Go to launcher, right-click your map, and click 'edit zone file', then add:
Code Snippet
Plaintext
fx,fx_file_name

Then obviously you need to thread the init() function, and the fx_light() function in your mapname.gsc, so put the fx light scripts into it's own gsc file, so the #namespace command makes the init() function local. Ex.
Code Snippet
Plaintext
//In your mapname.gsc
your_fx_script_gsc::init();          //<--Pre-load
zm_usermap::main();               //<-- Main - already in your mapname.gsc
your_fx_script_gsc::fx_light();  //<--Post-load

Hope this helps. I've done similar things with fx so I know this method works. However there are usually always multiple ways to do any one task in coding, generally speaking. As for the "link to" method, what you're looking for if you want to go that route is to use an offset on the z-axis, so the light spawns above the player and shines down on them. So, if you use the link to method, then do it like this:
Code Snippet
Plaintext
fx_follower = Spawn("script_model", player.origin + (0, 0, 80));
fx_follower SetModel("tag_origin");
fx_follower EnableLinkTo();
fx_follower LinkTo(player, "tag_origin", (0, 0, 80));
PlayFXOnTag(level._effect["your_fx"], fx_follower, "tag_origin");
//Then do:
fx_follower Delete();
//When you're ready to stop the fx
Last Edit: March 20, 2017, 11:31:04 am by Archaicvirus

 
Loading ...