UGX-Mods

Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: symbo on November 05, 2017, 12:00:03 pm

Title: Moving an fx?
Post by: symbo on November 05, 2017, 12:00:03 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);

}
Title: Re: Moving an fx?
Post by: buttkicker845 on November 06, 2017, 01:06:58 pm
you can move an FX, but what you will want to do is use the function named
Code Snippet
Plaintext
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:
Code Snippet
Plaintext
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"
Title: Re: Moving an fx?
Post by: Archaicvirus on November 29, 2017, 09:02:35 pm
you can move an FX, but what you will want to do is use the function named
Code Snippet
Plaintext
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:
Code Snippet
Plaintext
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:

Code Snippet
Plaintext
//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);
}