fix for spawnjumps?

Discussions about Coding and Scripting
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: fix for spawnjumps?

Post by sektor2111 »

How I would try to solve this ? By logging physics and velocity in a moment.
In this "modifyplayer" I would spawn a... sort of actor for 50 ms owned by player.
At end of life, actor will log velocity of owner and physics depending on environment... Else actor can live more or less time, telling what was going on with player.

By knowing that player has a sudden Z velocity, you can drop it to 0 zero on z axis = no more jumping.
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: fix for spawnjumps?

Post by nogardilaref »

I guess everyone missed my post?
nogardilaref wrote: As Jack said it's probably something not reset properly in terms of physics, either the state or even the Velocity, so the player keeps "jumping" or "falling" on an immediate respawn.
So one thing which comes to mind is to simply reset the player Velocity to vect(0,0,0) on respawn.
Perhaps there are other variables here at play which I am not remembering about, but this might do the trick.
Was this even tried and simply didn't work, or was it just overlooked?
sektor2111 wrote:nogardilaref mentioned that in this engine physics are flawed.
It's flawed, but not in the sense you probably think I meant. :)
It's about how the physics is calculated to put it simply, which causes things like projectiles, especially falling ones, to mismatch their positions between client and server over time during their simulation on both sides, depending on the tickrate difference between them.
It has nothing to do with the actual physics "states" themselves, those are generally fine.
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

Re: fix for spawnjumps?

Post by OwYeaW »

nogardilaref wrote:I guess everyone missed my post?
nogardilaref wrote: As Jack said it's probably something not reset properly in terms of physics, either the state or even the Velocity, so the player keeps "jumping" or "falling" on an immediate respawn.
So one thing which comes to mind is to simply reset the player Velocity to vect(0,0,0) on respawn.
Perhaps there are other variables here at play which I am not remembering about, but this might do the trick.
Was this even tried and simply didn't work, or was it just overlooked?
im sorry for not responding, but i already tried this and it didnt fix the spawnjumps
sektor2111 wrote:How I would try to solve this ? By logging physics and velocity in a moment.
In this "modifyplayer" I would spawn a... sort of actor for 50 ms owned by player.
At end of life, actor will log velocity of owner and physics depending on environment... Else actor can live more or less time, telling what was going on with player.

By knowing that player has a sudden Z velocity, you can drop it to 0 zero on z axis = no more jumping.
but what if a player purposely does a spawnjump (for example by holding walk and jump immediatelly after respawning)
i dont want to mess with a player's physics(physics in general) after a player has been spawned, because that could make differences in run times(speedrunning BT maps)
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: fix for spawnjumps?

Post by JackGriffin »

Here's the base code for respawning players

Code: Select all

// Restart a player.
//
function bool RestartPlayer( pawn aPlayer ) 
{
    local NavigationPoint startSpot;
    local bool foundStart;

    if( bRestartLevel && Level.NetMode!=NM_DedicatedServer && Level.NetMode!=NM_ListenServer )
        return true;

    startSpot = FindPlayerStart(aPlayer, 255);
    if( startSpot == None )
    {
        log(" Player start not found!!!");
        return false;
    }   
    foundStart = aPlayer.SetLocation(startSpot.Location);
    if( foundStart )
    {
        startSpot.PlayTeleportEffect(aPlayer, true);
        aPlayer.SetRotation(startSpot.Rotation);
        aPlayer.ViewRotation = aPlayer.Rotation;
        aPlayer.Acceleration = vect(0,0,0);
        aPlayer.Velocity = vect(0,0,0);
        aPlayer.Health = aPlayer.Default.Health;
        aPlayer.SetCollision( true, true, true );
        aPlayer.ClientSetLocation( startSpot.Location, startSpot.Rotation );
        aPlayer.bHidden = false;
        aPlayer.DamageScaling = aPlayer.Default.DamageScaling;
        aPlayer.SoundDampening = aPlayer.Default.SoundDampening;
        AddDefaultInventory(aPlayer);
    }
    else
        log(startspot$" Player start not useable!!!");
    return foundStart;
}
Like I posted before I think they accounted for everything with the exception that the physics state isn't being reset. If you died in the air and didn't run the subroutine of Landed then your physics was never changed from PHYS_Falling. Respawning might carry an incorrect value for physics now, especially if the spawnpoint is raised some and the player doesn't teleport in touching anything. Since the spawning player is detached from the ground and in the falling state the engine may be confused and think he is actually jumping and apply the acceleration.
So long, and thanks for all the fish
OwYeaW
Experienced
Posts: 81
Joined: Fri Jan 09, 2015 4:24 pm

Re: fix for spawnjumps?

Post by OwYeaW »

JackGriffin wrote:Here's the base code for respawning players

Code: Select all

// Restart a player.
//
function bool RestartPlayer( pawn aPlayer ) 
{
    local NavigationPoint startSpot;
    local bool foundStart;

    if( bRestartLevel && Level.NetMode!=NM_DedicatedServer && Level.NetMode!=NM_ListenServer )
        return true;

    startSpot = FindPlayerStart(aPlayer, 255);
    if( startSpot == None )
    {
        log(" Player start not found!!!");
        return false;
    }   
    foundStart = aPlayer.SetLocation(startSpot.Location);
    if( foundStart )
    {
        startSpot.PlayTeleportEffect(aPlayer, true);
        aPlayer.SetRotation(startSpot.Rotation);
        aPlayer.ViewRotation = aPlayer.Rotation;
        aPlayer.Acceleration = vect(0,0,0);
        aPlayer.Velocity = vect(0,0,0);
        aPlayer.Health = aPlayer.Default.Health;
        aPlayer.SetCollision( true, true, true );
        aPlayer.ClientSetLocation( startSpot.Location, startSpot.Rotation );
        aPlayer.bHidden = false;
        aPlayer.DamageScaling = aPlayer.Default.DamageScaling;
        aPlayer.SoundDampening = aPlayer.Default.SoundDampening;
        AddDefaultInventory(aPlayer);
    }
    else
        log(startspot$" Player start not useable!!!");
    return foundStart;
}
Like I posted before I think they accounted for everything with the exception that the physics state isn't being reset. If you died in the air and didn't run the subroutine of Landed then your physics was never changed from PHYS_Falling. Respawning might carry an incorrect value for physics now, especially if the spawnpoint is raised some and the player doesn't teleport in touching anything. Since the spawning player is detached from the ground and in the falling state the engine may be confused and think he is actually jumping and apply the acceleration.
i just tried this out, i added this line:

Code: Select all

		aPlayer.SetPhysics(PHYS_None);
it didnt fix the spawnjumps
i will experiment further with this RestartPlayer function

and btw, this "spawnjump bug" only happens when playing online
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: fix for spawnjumps?

Post by JackGriffin »

I don't think it's going to be that easy. There is a flow to spawning/initializing and you have to make sure you do what needs done at the proper time. That's why I suggested logging out the entire process and making a proper, albeit simple, flowchart.

You have to remember that when an actor spawns a lot of things are happening at once. It's being replicated across the network, relevancy for itself and surrounding actors is computed, default values are applied to the spawned actor, etc. If you change something out of sequence that change can go from causing weirdness to just being ignored and discarded.

Whenever I see a problem like this that appears simple but remains unfixed then I usually assume the answer is one of these "dig for a day and a half" deals that may or may not get an answer. Same thing happened with the Snow/Rain mod when I tried to fix the lingering particles. Simple problem with a deeply complex answer.

I wonder does the same behavior happen in Unreal? If not then we should post up at OU and ask Smirf/MasterKent. They very well may have fixed this and you'll have an easy answer. I'll ask them, I'm hooked now and I want the answer.
So long, and thanks for all the fish
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: fix for spawnjumps?

Post by nogardilaref »

Well, another idea would be to reset the physics of the player upon death, rather than trying to fix it on respawn.

Other than that, do not forget that there's a lot going on in the player code in particular for multiplayer, and so normal physics rules and resets may or may not apply at times, with things like ServerMove and the like, and flags to say whether or not the player is jumping like bJumpStatus, to name a few.
So you might have to dig into this and log as many things as you can to figure out what is causing this, like others have suggested.
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: fix for spawnjumps?

Post by sektor2111 »

Perhaps arguing with "SavedMove" previously added in that stack won't help until time is passing a bit.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: fix for spawnjumps?

Post by JackGriffin »

I've posted at OU and MasterKent responded. Can someone make a quick demo vid of the problem I can post there? I don't have anything BT installed at all. You don't need any production values or anything, just as simple a demonstration as you can toss together that shows the spawnjump bug.
So long, and thanks for all the fish
RocketJedi
Inhuman
Posts: 850
Joined: Wed Mar 12, 2008 7:14 pm
Personal rank: I.T Master
Location: New York
Contact:

Re: fix for spawnjumps?

Post by RocketJedi »

JackGriffin wrote:I've posted at OU and MasterKent responded. Can someone make a quick demo vid of the problem I can post there? I don't have anything BT installed at all. You don't need any production values or anything, just as simple a demonstration as you can toss together that shows the spawnjump bug.

I don't have the time to test at work, but on lowgrav BT maps would be a great example.
https://www.vulpinemission.com
Image ROCKET-X8 Server
Image MONSTERHUNT w/ NALI WEAPONS 3 + RX8
Image BUNNYTRACK NY
Image SNIPER DEATHMATCH
Image InstaGib + ComboGib + Jailbreak
Image ROSEBUM ROCKET-X RB
Post Reply