Frictional Games Forum (read-only)

Full Version: Player Effects
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to create the effect of the Player limping as they walk/run. How can I do this? I tried this code but it's not working:

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""AreaFallBreakLeg""Leg"true1);
}

void Leg(string &in asParentstring &in asChildint alState)
{
    
SetPlayerMoveSpeedMul(0.9);
    
SetPlayerRunSpeedMul(1);
    
AddTimer(""1"CheckLeg");
}

void CheckLeg(string &in asTimer)
{
    if(
GetPlayerSpeed() <= 0.9)
    {
        
AddTimer(""1"CheckLeg");
        
AddTimer(""0.5"HeadTilt");
    }
    
    if(
GetPlayerSpeed() == 1)
    {
        
AddTimer(""0.5"CheckLeg");
        
AddTimer(""0.3"HeadTilt");
    }
    if(
GetPlayerSpeed() == 0)
    {
        
AddTimer(""0.1"CheckLeg");
    }
}

void HeadTilt(string &in asTimer)
{
    if(
GetPlayerSpeed() <= 0.9)
    {
         
FadePlayerRollTo(450.50.5);
         
SetPlayerMoveSpeedMul(0);
        
AddTimer(""0.1"HeadNormal");
    }
    
    if(
GetPlayerSpeed() == 1)
    {
        
FadePlayerRollTo(450.20.2);
        
SetPlayerRunSpeedMul(0.6);
        
AddTimer(""0.05"HeadNormal");
    }
}

void HeadNormal(string &in asTimer)
{
    if(
GetPlayerSpeed() <= 0.9)
    {
         
FadePlayerRollTo(00.30.3);
         
SetPlayerMoveSpeedMul(0.9);
        
AddTimer(""0.5"HeadTilt");
    }
    
    if(
GetPlayerSpeed() == 1)
    {
        
FadePlayerRollTo(00.20.2);
        
SetPlayerRunSpeedMul(1);
        
AddTimer(""0.1"HeadTilt");
    }

Please make sure to post in the development support section for questions, thanks!
What isn't working? Does the code execute? If so, where does it stop?
(03-17-2015, 01:11 PM)Romulator Wrote: [ -> ]What isn't working? Does the code execute? If so, where does it stop?

The code seems to run but the head position doesn't change, it stays normal. I'm going to add debug messages to make sure everything is working as it should.
(03-17-2015, 09:48 PM)dailycreepypasta Wrote: [ -> ]
(03-17-2015, 01:11 PM)Romulator Wrote: [ -> ]What isn't working? Does the code execute? If so, where does it stop?

The code seems to run but the head position doesn't change, it stays normal. I'm going to add debug messages to make sure everything is working as it should.

I think that's because speed is set to something like 0.5.
It's not speed in seconds IIRC. Smaller numbers = slower-