Frictional Games Forum (read-only)
Is there any way to attach particle effects to enemy's animation? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Is there any way to attach particle effects to enemy's animation? (/thread-30544.html)



Is there any way to attach particle effects to enemy's animation? - DarkPearStudios - 09-12-2015

Hello everyone!

So, I want to know if is there a way to attach a particle effect to an enemy animation. More specifically, the attack animation.

And if there's a way to delay the particle effect. Explaining better, when the animation starts, it takes like 0,5 seconds to the attack really happen, so I want to know if there is a way to delay the particle effect and that it just spawn in the right time.

Thanks!

Gabriel.


RE: Is there any way to attach particle effects to enemy's animation? - Neelke - 09-12-2015

I don't think so. You can attach a particle to the enemy directly, but it doesn't update with the enemy's movement later on, making it look completely awful. You can try to experiment with it if you wish, but if you attach it directly, it's gonna stay there forever with the enemy.


RE: Is there any way to attach particle effects to enemy's animation? - Romulator - 09-12-2015

Is the animation needing to happen when it hurts the player? Or regardless of whether it touches the player or not? If that's the case, you might be able to make something happen with AddEntityCollideCallbacks, but as Neelke above me states, attaching the particle doesn't update with movement.


RE: Is there any way to attach particle effects to enemy's animation? - DarkPearStudios - 09-12-2015

Well... The particle should spawn every time that the attack animation plays for hurt the player. Example: You're being chased and the enemy gets near you and then he hurts you. The particle should spawn when the enemy hurts you.


RE: Is there any way to attach particle effects to enemy's animation? - Romulator - 09-12-2015

I threw this together in about 10 minutes. It may or may not work; it is untested, but it gives you a general idea of what I would do if it does work.

PHP Code:
//Make sure to read over this code. I didn't test it, so there is probably mistakes.
//Furthermore, never copy+paste code unless you're sure what it does.
//I put some internal documentation if it helps you understand what is going on~
//Feel free to remove it later.

void OnStart()
{
    
AddEntityCollideCallback("Player""servant_grunt_x""check_collide"true0);     //Change enemy name. Cannot be (*).
}

void check_collide(string &in asParentstring &in asChildint alState)
{
    
RemoveCallback(asParentasChild);                            //Stop checking constantly. Comment it out if nothing is working.
    
if(GetPlayerHealth() <> GetLocalVarFloat("player_health")    //Checks if Player health does not equal placeholder float.
    
{
        
SetLocalVarFloat("player_health"GetPlayerHealth());    //Sets placeholder float to the same value as Player's health.
    
}                                                            //It's unlikely that the player will hurt themself
    
AddTimer("anim_trigger"1.0f"play_animation");            //Other than from an enemy in 1 second. Change timer 
}                                                                //if you need it earlier/later.

void play_animation(string &in asTimer)
{
    if(
GetPlayerHealth GetLocalVarFloat("player_health"))        
    {
        
//Run all your CreateParticleSystemAtEntity and anything else here~
        //It will only run this if the Player's health is lower than what it was earlier.
        //Then will run through to re-adding the CollideCallback and resetting the Float.
    
}
    
AddEntityCollideCallback("Player""servant_grunt_x""check_collide"true0);    //Change enemy name.
    
SetLocalVarFloat("player_health"GetPlayerHealth());                                //Comment out Callback if RemoveTimer is also.




RE: Is there any way to attach particle effects to enemy's animation? - The chaser - 09-12-2015

Humm I actually did this with a monster of mine, you can attach particles to the monster bones, and the particles will move along with it, as far as I know. Dunno if this is what you are currently searching, I hope I helped tho Smile


RE: Is there any way to attach particle effects to enemy's animation? - Traggey - 09-12-2015

This belongs in the development support forum, I have moved the thread.


RE: Is there any way to attach particle effects to enemy's animation? - DarkPearStudios - 09-13-2015

(09-12-2015, 03:25 AM)Romulator Wrote: I threw this together in about 10 minutes. It may or may not work; it is untested, but it gives you a general idea of what I would do if it does work.

PHP Code:
//Make sure to read over this code. I didn't test it, so there is probably mistakes.
//Furthermore, never copy+paste code unless you're sure what it does.
//I put some internal documentation if it helps you understand what is going on~
//Feel free to remove it later.

void OnStart()
{
    
AddEntityCollideCallback("Player""servant_grunt_x""check_collide"true0);     //Change enemy name. Cannot be (*).
}

void check_collide(string &in asParentstring &in asChildint alState)
{
    
RemoveCallback(asParentasChild);                            //Stop checking constantly. Comment it out if nothing is working.
    
if(GetPlayerHealth() <> GetLocalVarFloat("player_health")    //Checks if Player health does not equal placeholder float.
    
{
        
SetLocalVarFloat("player_health"GetPlayerHealth());    //Sets placeholder float to the same value as Player's health.
    
}                                                            //It's unlikely that the player will hurt themself
    
AddTimer("anim_trigger"1.0f"play_animation");            //Other than from an enemy in 1 second. Change timer 
}                                                                //if you need it earlier/later.

void play_animation(string &in asTimer)
{
    if(
GetPlayerHealth GetLocalVarFloat("player_health"))        
    {
        
//Run all your CreateParticleSystemAtEntity and anything else here~
        //It will only run this if the Player's health is lower than what it was earlier.
        //Then will run through to re-adding the CollideCallback and resetting the Float.
    
}
    
AddEntityCollideCallback("Player""servant_grunt_x""check_collide"true0);    //Change enemy name.
    
SetLocalVarFloat("player_health"GetPlayerHealth());                                //Comment out Callback if RemoveTimer is also.



Hi,

Thanks for this code. I will send this code to the programmer of the mod that I'm working.
The mod is Subconscientia, If you want to take a look. Then he sees if it works. Although I don't think that my idea would be possible without modifying the engine.

(09-12-2015, 02:52 PM)The chaser Wrote: Humm I actually did this with a monster of mine, you can attach particles to the monster bones, and the particles will move along with it, as far as I know. Dunno if this is what you are currently searching, I hope I helped tho Smile

Hello.

I don't think that attaching the particle to the bones would work. I was trying to do this with the pigs, to make them vomit instead of the common attack animation (I wrote attack animation for the people undestand.) but the vomit animation is not helping. I know how to make a "scene" with the pig vomiting, but to make this as an attack... I think it's not possible.

I have been in a LONG conversation with Peter Howeel, the co-designer of AAMFP, to talk about the development of Pigs and changes made during it. ( he explained some changes) and I asked him about attaching the particles to the pigs and this was his answer:

"The particles being attached to the pig animations was hardcoded into the engine, so it isn't accessible through script. I'm not a programmer so I don't know the technicalities of it I'm afraid! Smile"

But I will see what I can do. But thanks for your reply!


RE: Is there any way to attach particle effects to enemy's animation? - Romulator - 09-13-2015

No problem. Feel free to PM me later if you need help with other stuff, or of course, make a forum post. Most, if not all of us would be glad to help Smile