1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

adding velocities ...

Discussion in 'Ask a Coder' started by navboy, Jan 22, 2002.

  1. navboy

    navboy New Member

    Joined:
    Jan 5, 2001
    Messages:
    340
    Likes Received:
    0
    I just made a mover that a player can stand on that goes pretty fast, but when i jump i get left far behind, and when i fire a rocket forward it flies back in my face.

    So it looks to me like the player's velocity is not affected by the velocity of the mover, and in turn i don't know whether the rocket's velocity is affected by the player's velocity since the player's velocity isn't correct.

    Anyone know how to make these velocites add to each other the way they should? I didn't see an obvious place in the mover code for it, and it's not a custom gametype so i can't modify the players themselves any ...
     
  2. Kangus

    Kangus Zombie on your pwn!

    Joined:
    Jan 29, 2001
    Messages:
    978
    Likes Received:
    0
    well, the DoJump function in playerpawn only adds the Z (vertical) velocity of the player's base (whatever they are standing on) when called.
    Also, the player's velocity does not affect the rocket's velocity with the default UT rocket launcher at all. Its not coded to.

    I don't know much about mover code, but you might be able to solve the problem with a new zone type that changes its gravity (x, y or Z) when triggered (at the same time the mover is triggered of course).
     
  3. navboy

    navboy New Member

    Joined:
    Jan 5, 2001
    Messages:
    340
    Likes Received:
    0
    well the mover's not at a constant velocity the whole time, plus there are other problems ....

    hmmm ...

    I'm wondering about the feasibility of putting some code in the mover's Timer() function along the lines of:

    local Pawn P;

    if ( StandingCount > 0 )
    for ( P=Level.PawnList; P!=None; P=P.nextPawn )
    if ( P.Base == self )
    {
    P.SomethingToAffectVelocity();
    }


    but i'm not sure what i can do to affect the pawn's velocity or if this approach would have unseen nasty side effects in network play ...

    If i just did P.Velocity += Velocity type of thing it would just keep ramping up the pawn's velocity, so that won't work ....
     
  4. Kangus

    Kangus Zombie on your pwn!

    Joined:
    Jan 29, 2001
    Messages:
    978
    Likes Received:
    0
    yeah, that sounds solid aside from the SomethingToAffectVelocity() function... not sure what you'd put in there.
     
  5. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    What about:

    if ( P.Physics != PHYS.Falling ) // If they're falling and thus have jumped
    {
    P.AddVelocity ( Velocity ); // Add the velocity of the mover to the foo's jump velocity
    }

    Not sure if you need vect or vector in front of Velocity. I can never remember that.
     
  6. navboy

    navboy New Member

    Joined:
    Jan 5, 2001
    Messages:
    340
    Likes Received:
    0
    Interesting you mention that i tried something very similar a while ago. Every second (in mover's Timer() ) i called the pawns addvelocity and added the mover velocity (and addvelocity itself sets the pawn's physics to falling) ... but it didn't have any effect at all. I thought for sure it would keep adding the mover's velocity to the pawn's velocity resulting in some insane velocity for the pawn.

    But as i ride on the mover, nothing's any different than normal, and when i jump up, i go straight up, with no horizontal velocity whatsoever. I starting to think the game code itself ignores anything but z velocity when you jump; i guess it took jumping from a very fast mover to make me realize it.

    I'm still looking for a way to make this work however ;)
     
  7. navboy

    navboy New Member

    Joined:
    Jan 5, 2001
    Messages:
    340
    Likes Received:
    0
    Hey i got it working! The Inventory actor has a OwnerJumped() function so i added it to a subclass i made of TournamentPickup and put a trigger around each PlayerStart that gives the player a copy of it. Then i added this function:

    function OwnerJumped()
    {
    local Pawn PawnOwner;

    PawnOwner = Pawn(Owner);
    if ( (PawnOwner.Base != Level) && (PawnOwner.Base != None) )
    {
    PawnOwner.Velocity.X += PawnOwner.Base.Velocity.X;
    PawnOwner.Velocity.Y += PawnOwner.Base.Velocity.Y;
    }


    I guess my question now is am i causing any unforeseen problems by adding an extra inventory item to the player, and if i wanted to investigate your Detached() approach to compare to this one would i be using the mover's Detach function?
     

Share This Page