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

Moving an fx?

broken avatar :(
Created 4 years ago
by symbo
0 Members and 1 Guest are viewing this topic.
1,292 views
broken avatar :(
×
broken avatar :(
Location: ch
Date Registered: 14 November 2014
Last active: 3 years ago
Posts
1
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
symbo's Groups
symbo's Contact & Social Links
Is it possible to move an fx, that we spawned or not?

This script spawn the model and the fx but doesn't move the fx:

function move_fx()
{
level flag::wait_till( "initial_blackscreen_passed" );
struct1 = struct::get("struct1","targetname");
level.model = spawn( "script_model", struct1.origin );
level.model SetModel( "p7_skulls_bones_head_02" );
level._effect["bouledefeu"] = "Symbo/test3";
PlayLoopedFX(level._effect["bouledefeu"], 1, struct1.origin);
level.model enablelinkto();
level._effect["bouledefeu"] linkto(level.model);
fx_trigger = GetEnt("fx_trigger", "targetname");
fx_trigger waittill("trigger", player);
level.model moveY(-338,2);

}
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 months ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
you can move an FX, but what you will want to do is use the function named
fx = playfxontag(id, ent, tag);
where 'id' is the FX id, ent is the script_model that you want to play the FX on, and tag is the model tag you where you want the FX attached.
example:
fx = PlayFxOnTag(level._effect["bouledefeu"], level.model, "tag_origin");
PS: if you ran it in developer mode you should have gotten an error saying "Type String is not an entity and cannot call EnableLinkTo"
broken avatar :(
×
broken avatar :(
Location: usSouth Florida
Date Registered: 10 July 2016
Last active: 6 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
you can move an FX, but what you will want to do is use the function named
fx = playfxontag(id, ent, tag);
where 'id' is the FX id, ent is the script_model that you want to play the FX on, and tag is the model tag you where you want the FX attached.
example:
fx = PlayFxOnTag(level._effect["bouledefeu"], level.model, "tag_origin");

PS: if you ran it in developer mode you should have gotten an error saying "Type String is not an entity and cannot call EnableLinkTo"


Close, but no cigar. According to the api (root/docsmodtools/bo3_scriptapifunctions.html) search for playfxontag. I use a lot of custom fx in my projects and am familiar with this topic. Im on standby at work right now, but give me an hour and I'll give you (original poster) a proper example once I get home. (On mobile)

Double Post Merge: November 29, 2017, 11:55:48 pm
Is it possible to move an fx, that we spawned or not?

This script spawn the model and the fx but doesn't move the fx:

function move_fx()
{
level flag::wait_till( "initial_blackscreen_passed" );
struct1 = struct::get("struct1","targetname");
level.model = spawn( "script_model", struct1.origin );
level.model SetModel( "p7_skulls_bones_head_02" );
level._effect["bouledefeu"] = "Symbo/test3";
PlayLoopedFX(level._effect["bouledefeu"], 1, struct1.origin);
level.model enablelinkto();
level._effect["bouledefeu"] linkto(level.model);
fx_trigger = GetEnt("fx_trigger", "targetname");
fx_trigger waittill("trigger", player);
level.model moveY(-338,2);

}

This should help you out:

//First, you need to pre-cache your fx file before init(). (Certain fx are pre-cached by default, there is a list in the forums here)
#precache("fx", "Symbo/test3");

function init()
{
level flag::wait_till("initial_blackscreen_passed");
level._effect["bouledefeu"] = "Symbo/test3"; //Defining the fx

temp = struct::get("struct1", "targetname");
//In radiant, put a new struct where the skull moves to - name it "destination"
destination = struct::get("destination", "targetname");
skull = Spawn("script_model", temp.origin);
skull SetModel("p7_skulls_bones_head_02");
skull.destination = destination.origin;

temp Delete(); //If only using as an origin point - no longer needed
destination Delete();

fx_trigger = GetEnt("fx_trigger", "targetname");
fx_trigger waittill("trigger");
skull thread move_fx();
}

//level.model enablelinkto();
//level._effect["bouledefeu"] linkto(level.model);
//***You do not call EnableLinkTo() on the fx ^ or the model here. The fx in gsc is only a string pointing to the fx file,
//PlayFXOnTag() solves that, the fx will move with the model

function move_fx()
{
PlayFXOnTag(level._effect["bouledefeu"], self, "tag_origin");
//If you want to get fancy, you could make the skull look towards the destination point as it moves there
//I wrote an easy function for that at the bottom of the page
self face_target(self.destination);
//Then move it there
self MoveTo(self.destination, 2);

//If feeling extra fancy you could make the skull 'look' at the nearest player
while(1)
{
players = GetPlayers();
searchDist = 500; //500 is the search distance for players - change as needed
nearestPlayer = ArrayGetClosest(self.origin, players, searchDist);

if(!isdefined(nearestPlayer) || Distance2D(self.origin, nearestPlayer.origin) > searchDist)
{
wait(1);
}
else
{
target = nearestPlayer GetTagOrigin("tag_eye");
self face_target(target);
wait(0.2);
}
}
}

//Syntax: <entity> face_target(<vector3>)
function face_target(target)
{
vectorToFace = self.origin - target;
angleToFace = VectortoAngles(vectorToFace);
self RotateTo(angleToFace, 0.25);
}

Last Edit: November 30, 2017, 12:03:10 am by Archaicvirus

 
Loading ...