UE3 - UDK Player Inherits Velocity of Mover

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

inferyes

Spaced In
Aug 16, 2009
504
0
0
I'm starting my first UDK project and I have 1 little problem with the physics. If a player is standing on a platform that is moving at a constant rate on the X axis and he jumps he jumps straight up and does not inherit the X velocity of the object he was standing on. I need make it so when a player jumps off of a moving object he inherits the velocity of the object. I can post a video if my explanation if not clear enough.

I haven't found anything in the mover properties to change this setting so I'm guessing I'll have to do this in Uscript. Do you any of you guys know where I should look?
 

inferyes

Spaced In
Aug 16, 2009
504
0
0
No one has any idea? That's surprising, I thought this would be something simple that I messed up.
 

brold9999

New Member
Apr 5, 2009
142
0
0
I thought that this was the default behaviour for movers. I could be wrong or it could have changed. It can be done in UScript if nothing else, though there may be a more approachable way to do it. I haven't the time to investigate at this point but I would start by looking at the player's jumping-related code.
 

inferyes

Spaced In
Aug 16, 2009
504
0
0
Alright.

Here is what there is:

Code:
	if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
	{
		if ( Physics == PHYS_Spider )
			Velocity = JumpZ * Floor;
		else if ( Physics == PHYS_Ladder )
			Velocity.Z = 0;
		else if ( bIsWalking )
			Velocity.Z = Default.JumpZ;
		else
			Velocity.Z = JumpZ;
		if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f)
		{
			if ( (WorldInfo.WorldGravityZ != WorldInfo.DefaultGravityZ) && (GetGravityZ() == WorldInfo.WorldGravityZ) )
			{
				Velocity.Z += Base.Velocity.Z * sqrt(GetGravityZ()/WorldInfo.DefaultGravityZ);
			}
			else
			{
				Velocity.Z += Base.Velocity.Z;
			}
		}
		SetPhysics(PHYS_Falling);
		bReadyToDoubleJump = true;
		bDodging = false;
		if ( !bUpdating )
		    PlayJumpingSound();
		return true;
	}

I'm betting it's the SetPhysics(PHYS_Falling); that causes the player not to inherit the movers velocity. Is there anyway to make it so I can get the movers velocity and add it to the jump velocity? I'm not sure how to do it though. Maybe some sort of touch command that checks if the object touching the player is a mover and then grabbing its velocity?
 

inferyes

Spaced In
Aug 16, 2009
504
0
0
Woop, figured it out. There was already a call to add the velocity of a base to the Z axsis so I just rewrote it and added it to where I needed to and put in a few logs to tell me what kind of physics jump occurs.

Code:
function bool DoJump( bool bUpdating )
{
    // This extra jump allows a jumping or dodging pawn to jump again mid-air
    // (via thrusters). The pawn must be within +/- DoubleJumpThreshold velocity units of the
    // apex of the jump to do this special move.
    if ( !bUpdating && CanDoubleJump()&& (Abs(Velocity.Z) < DoubleJumpThreshold) && IsLocallyControlled() )
    {
        if ( PlayerController(Controller) != None )
            PlayerController(Controller).bDoubleJump = true;
        DoDoubleJump(bUpdating);
        MultiJumpRemaining -= 1;
        return true;
    }

    if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
    {
        if ( Physics == PHYS_Spider )
            Velocity = JumpZ * Floor;
        else if ( Physics == PHYS_Ladder )
        {
            Velocity.Z = 0;
            loginternal("1");
        }
        else if ( bIsWalking )
        {
            Velocity.Z = Default.JumpZ;
            loginternal("2");
        }
        else
        {
            Velocity.Z += Base.Velocity.Z;
            Velocity.Y += Base.Velocity.Y;
            Velocity.X += Base.Velocity.X;
            loginternal("3");
        }
        if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f)
        {
            if ( (WorldInfo.WorldGravityZ != WorldInfo.DefaultGravityZ) && (GetGravityZ() == WorldInfo.WorldGravityZ) )
            {
                Velocity.Z += Base.Velocity.Z * sqrt(GetGravityZ()/WorldInfo.DefaultGravityZ);
                Velocity.Y += Base.Velocity.Y;
                Velocity.X += Base.Velocity.X;
                loginternal("4");
            }
            else
            {
                Velocity.Z += Base.Velocity.Z;
                Velocity.Y += Base.Velocity.Y;
                Velocity.X += Base.Velocity.X;
                loginternal("5");
            }
        }
        SetPhysics(PHYS_Falling);
        bReadyToDoubleJump = true;
        bDodging = false;
        if ( !bUpdating )
            PlayJumpingSound();
        return true;
    }
    return false;
}

For anyone interested.
 
Last edited: