Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there any way to attach particle effects to enemy's animation?
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#5
RE: Is there any way to attach particle effects to enemy's animation?

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: (Select All)
//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.


Discord: Romulator#0001
[Image: 3f6f01a904.png]
09-12-2015, 03:25 AM
Find


Messages In This Thread
RE: Is there any way to attach particle effects to enemy's animation? - by Romulator - 09-12-2015, 03:25 AM



Users browsing this thread: 1 Guest(s)