Author Topic: Making player float in air more efficently without sinking/falling down?  (Read 1074 times)

Okay guys, so, I have this ledge grab loop function over here that makes player float in air, giving the "Grabbing brick" effect.
But the problem is... It's sinking downwards. Slowly, but it still does it.
Here's the function:
Code: [Select]
function Player::parkourGrabLoop( %this )
{
    cancel( %this.parkourGrabLoop );
    if ( !isObject( %this ) )
    {
        return;
    }
    if ( !%this.isGrabbing )
    {
        %this.changeDatablock(PlayerParkourArmor.getID());
        return;
    }

    %this.changeDatablock(PlayerStaticArmor.getID());
    %this.addVelocity( "0 0 0.64" );
    %this.setVelocity( "0 0 0.64" );
    %this.parkourGrabLoop = %this.schedule( 32, "parkourGrabLoop" );
}

Any alternatives or better values?

Post your PlayerStaticArmor datablock.

It's a bit hacky, but you could change them to a low-mass playertype while they're grabbing.

what if you were to put something under them? a mix of truce's auto bridge and kalph's elevator

what if you were to put something under them? a mix of truce's auto bridge and kalph's elevator
Invisible auto bridge?

Or instead of just adding upwards velocity, get their position when they grab and keep resetting them to it.

Code: [Select]
function Player::parkourGrabLoop( %this , %pos)
{
    cancel( %this.parkourGrabLoop );
    if ( !isObject( %this ) )
    {
        return;
    }
    if ( !%this.isGrabbing )
    {
        %this.changeDatablock(PlayerParkourArmor.getID());
        return;
    }
    if ( !%pos )
    {
        %pos = %this.getPosition();
    }

    %this.changeDatablock(PlayerStaticArmor.getID());
    %tempRot = getWords(%this.getTransform(),3,6);
    %this.setTransform(%pos SPC %tempRot);
    %this.parkourGrabLoop = %this.schedule( 32, "parkourGrabLoop" , %pos);
}
This is untested and was written on my phone, no guarantees.
« Last Edit: August 04, 2012, 12:02:01 PM by lilboarder32 »


The main problem with the code in the op is that it will work up until the server lags. The best thing you can do is a mix of lil's code and the original code. If the player has shifted a certain amount, move them back to where they need to be

i feel like either way would have a jerky falling/teleporting up, or is it fast enough to not have that?
if it does, something solid and invisible under the player might look better for them

i feel like either way would have a jerky falling/teleporting up, or is it fast enough to not have that?
if it does, something solid and invisible under the player might look better for them
i dont think 32 ms is fast enough to not lag

Or instead of just adding upwards velocity, get their position when they grab and keep resetting them to it.

Code: [Select]
function Player::parkourGrabLoop( %this , %pos)
{
    cancel( %this.parkourGrabLoop );
    if ( !isObject( %this ) )
    {
        return;
    }
    if ( !%this.isGrabbing )
    {
        %this.changeDatablock(PlayerParkourArmor.getID());
        return;
    }
    if ( !%pos )
    {
        %pos = %this.getPosition();
    }

    %this.changeDatablock(PlayerStaticArmor.getID());
    %tempRot = getWords(%this.getTransform(),3,6);
    %this.setTransform(%pos SPC %tempRot);
    %this.parkourGrabLoop = %this.schedule( 32, "parkourGrabLoop" , %pos);
}
This is untested and was written on my phone, no guarantees.

This will still look like he is falling.

The best thing you can do is a mix of lil's code and the original code.

No, the best thing to do would get the player type not falling using datablock fields, as previously mentioned. Doing it by scheduled scripting is always going to be susceptible to lag. Doing it by datablock fields will stop the client-side emulating gravity and won't have that choppy jumping. What fields you would need to edit, I don't know but I would start with mass.

wouldn't you need to change the playertype then? what would be so bad about making a tiny platform under their feet?

wouldn't you need to change the playertype then? what would be so bad about making a tiny platform under their feet?
it's obviously because a duck is suggesting it. this looks like one of the better solutions to me.