Jump to content

Attaching a particle effect to a head prop


Shuma22

Recommended Posts

I've been trying for the past few days to attach an effect to a helmet i'm working on, and i can't figure out how to do it. I think the closest i got is this

 

https://udn.epicgames.com/Three/SkeletalMeshSockets.html#Attaching%20a%20component%20to%20a%20socket

 

My problem is that i don't know where i should put the unreal script, if it should have a specific name or if another file needs to reference the unreal script. Right now i have the rigged helmet with a socket and a particle effect with the bone/Socket Location modules as per this tutorial:

 

https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/EffectsGallery/1_G/index.html

 

Unfortunately this tutorial doesn't help me with applying the effect to a helmet, i don't think.

Link to comment
Share on other sites

Another option for playing particle effects is via an XComPerkContent archetype.

 

This archetype is primarily used for particle effects that are linked to abilities/effects. Although you can sort of cheat around that by creating a persistent ability that doesn't really do anything :).

Link to comment
Share on other sites

Well thanks for the help, but unfortunately i give up. I did try both methods but while i could easily add the notify to one of the soldier animations, i couldn't even save my package with the edited animationset in it to test it, not to mention that i would probably have to add the effect to a lot of animations if i want it to always be on, and while i could create a perk archetype, creating an ability is beyond my abilities. I think fiddling with animations and abilities is beyond the scope of what i'm trying to do anyway, i just wanted to put a lamp on a cosmetic hat, so i'll just slap an overly bright emisive texture on it and call it a day.

Link to comment
Share on other sites

I don't think you need to give up just yet on creating an ability to add a particle effect to the helmet. I've done something similar in the past, and I think it shouldn't be too onerous. Here's the basics of what you need.

 

First, the X2Effect class that will play the effect attached to the socket:

// This is the effect that plays the particle effect attached to a socket
class X2Effect_YourModNameHere_ParticleEffect extends X2Effect_Persistent;

var name FXSocketName, FXEffectName;

private function DoTargetFX(XComGameState_Effect TargetEffect, out VisualizationTrack BuildTrack, XComGameStateContext Context, name EffectApplyResult, bool bStopEffect)
{
	local XComGameState_Unit	PrimaryTarget;
	local X2Action_PlayEffect	PlayEffectAction;
	
	if (FXSocketName == none)
	{
		`RedScreen("Forgot to assign the socket name.");
		return;
	}
	if (FXEffectName == none)
	{
		`RedScreen("Forgot to assign the effect name.");
		return;
	}

	PrimaryTarget = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(TargetEffect.ApplyEffectParameters.AbilityInputContext.PrimaryTarget.ObjectID));
	
	if (PrimaryTarget != none)
	{
		// Play the effect animation for the detected unit
		PlayEffectAction = X2Action_PlayEffect(class'X2Action_PlayEffect'.static.AddToVisualizationTrack(BuildTrack, Context));

		PlayEffectAction.EffectName = FXEffectName;
		// Okay, this is where my offhand knowledge breaks down. There are one or two more properties we need to set
		// on this action, including the socket name, but I don't know what they are and I don't have the source available
		// to me right now to look it up. I'll do so when I get home
		PlayEffectAction.SOMETHING = SOMETHING;
		PlayEffectAction.bStopEffect = bStopEffect;
	}
	else (TargetEffect == none)
	{
		`RedScreen("Could not find unit state.");
		return;
	}
}

simulated function AddX2ActionsForVisualization(XComGameState VisualizeGameState, out VisualizationTrack BuildTrack, name EffectApplyResult)
{
	local XComGameState_Effect TargetEffect;

	if (EffectApplyResult != 'AA_Success')
	{
		// We're only going to visualize the Awareness active effect when it applies successfully
		return;
	}

	foreach VisualizeGameState.IterateByClassType(class'XComGameState_Effect', TargetEffect)
	{
		if( TargetEffect.GetX2Effect() == self )
		{
			break;
		}
	}

	if (TargetEffect != none)
	{
		DoTargetFX(TargetEffect, BuildTrack, VisualizeGameState.GetContext(), EffectApplyResult, false);
	}
	else
	{
		`RedScreen("Could not find effect state.");
	}
}

simulated function AddX2ActionsForVisualization_Sync(XComGameState VisualizeGameState, out VisualizationTrack BuildTrack)
{
	// We assume 'AA_Success', because otherwise the effect wouldn't be here (on load) to get sync'd
	AddX2ActionsForVisualization(VisualizeGameState, BuildTrack, 'AA_Success');
}

simulated function AddX2ActionsForVisualization_Removed(XComGameState VisualizeGameState, out VisualizationTrack BuildTrack, const name EffectApplyResult, XComGameState_Effect RemovedEffect)
{
	DoTargetFX(RemovedEffect, BuildTrack, VisualizeGameState.GetContext(), EffectApplyResult, true);
}

Second the X2AbilityTemplate class for the ability that applies the X2Effect to the unit:

class X2Ability_YourModNameHere_AbilitySet extends X2Ability;

// This method is natively called for subclasses of X2DataSet. Create and return the ability template
static function array<X2DataTemplate> CreateTemplates()
{
	local array<X2DataTemplate> Templates;
	
	Templates.Length = 0;
	Templates.AddItem(ParticleEffectAbility());

	return Templates;
}

static function X2AbilityTemplate ParticleEffectAbility()
{
	local X2AbilityTemplate				Template;
	local X2Effect_YourModNameHere_ParticleEffect	ParticleEffect;

	`CREATE_X2ABILITY_TEMPLATE(Template, 'YourModNameHere_ParticleEffectAbility');

	Template.AbilitySourceName = 'eAbilitySource_Perk';
	Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_NeverShow;// Doesn't show up on the unit's action bar
	Template.Hostility = eHostility_Neutral;
	Template.bIsPassive = true;

	Template.AbilityToHitCalc = default.DeadEye;
	Template.AbilityTargetStyle = default.SelfTarget;
	Template.AbilityTriggers.AddItem(default.UnitPostBeginPlayTrigger);

	// This effect will perform the creation and attachment of the particle effect
	ParticleEffect = new class'X2Effect_YourModNameHere_ParticleEffect';
	ParticleEffect.EffectName = 'YourModNameHere_ParticleEffect';
	ParticleEffect.BuildPersistentEffect(1, true, false); // Make the effect last forever
	ParticleEffect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.LocLongDescription, Template.IconImage, false,, Template.AbilitySourceName); // Hide the effect so it doesn't show up on the unit status
	ParticleEffect.DuplicateResponse = eDupe_Ignore;
	ParticleEffect.FXSocketName = 'YourSocketNameHere';
	ParticleEffect.FXEffectName = 'YourFXNameHere';
	Template.AddTargetEffect(ParticleEffect);

	Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
	// This function will (I think) call effect's visualization function, which is where we'll attach the particle effect
	Template.BuildVisualizationFn = TypicalAbility_BuildVisualization;

	return Template;
}

Lastly, have the item give the dummy ability to the unit that equips it by adding this line to the item template definition:

	Template.Abilities.AddItem('YourModNameHere_ParticleEffectAbility');
Edited by Lucubration
Link to comment
Share on other sites

I was thinking that the PsiAmps might be where to look because they've got a persistent particle effect attached to them. I cant find anything pointing me in the right direction though.

 

edit: Eugh, no it's part of the weapon archetype.

Edited by Synthorange
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...