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.

Silly Flak Grenade Physics

Discussion in 'Ask a Coder' started by WheatPuppet, Jan 25, 2002.

  1. WheatPuppet

    WheatPuppet Corriganism

    Joined:
    Jan 22, 2002
    Messages:
    85
    Likes Received:
    0
    I was messing around with a flak-grenade type weapon and I was trying to figure out how to make it arc correctly, but I seem to be having trouble.
    The flak grenade uses Physics="PHYS_Falling" in default properties to make it arc the way it does, but this arc is too extreme. Is there a way of making it arc only slightly over a long distance?
    I'm a newbie coder, so I am not really sure what I can and can't do.

    BTW- What exactly does the CalcDrawOffset function do. The name suggests that it might have to do with the discrepancy between "internal" viewpoint (the player view) and an "external" viewpoint. I can't be sure though.
     
  2. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,910
    Likes Received:
    35
    Try this in the flak shell's Tick() function:
    Code:
    Velocity -= 0.3 * Region.Zone.ZoneGravity;
    Adjust the 0.3 to fit your needs.

    CalcDrawOffset() returns a vector for drawing the weapon in 1st person view (see Weapon.RenderOverlays() for details)
     
  3. EasyRaider

    EasyRaider Crazy coder

    Joined:
    Sep 21, 2001
    Messages:
    74
    Likes Received:
    0
    That code would be frame rate dependant. A Timer() might be better.

    (edit)
    Or something like:
    Code:
    Acceleration = 0.5 * Region.Zone.ZoneGravity();
    
     
    Last edited: Jan 29, 2002
  4. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,910
    Likes Received:
    35
    Oops, you're right. Actually it should be:
    Code:
    simulated function Tick(float DeltaTime)
    {
        ...
        Velocity -= 0.3 * Region.Zone.ZoneGravity * DeltaTime;
    }
    
    Acceleration won't do anything because Physics is set to PHYS_Falling.
     
  5. WheatPuppet

    WheatPuppet Corriganism

    Joined:
    Jan 22, 2002
    Messages:
    85
    Likes Received:
    0
    Umm, thanks.
    How is it that you figure out all these esoteric class references?
     
  6. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,910
    Likes Received:
    35
    What class references?
    Region.Zone.ZoneGravity?
     
  7. EasyRaider

    EasyRaider Crazy coder

    Joined:
    Sep 21, 2001
    Messages:
    74
    Likes Received:
    0
    I didn't know that. But you wouldn't want PHYS_Falling when you're doing your own gravity anyway.
     
  8. Kangus

    Kangus Zombie on your pwn!

    Joined:
    Jan 29, 2001
    Messages:
    978
    Likes Received:
    0
    simple answer.... I shoulda said this ages ago.
    Reduce the grenade's mass in its default properties, this should make its arc longer. The default mass for most things seems to be 100....
     
  9. EasyRaider

    EasyRaider Crazy coder

    Joined:
    Sep 21, 2001
    Messages:
    74
    Likes Received:
    0
    You mean the native physics code makes less massive objects fall slower? :eek: I refuse to believe the physics are that bad coded...
     
  10. WheatPuppet

    WheatPuppet Corriganism

    Joined:
    Jan 22, 2002
    Messages:
    85
    Likes Received:
    0
    That would be awfully daft!
    Remember... 9.8 m/s^2.... 9.8 m/s^2
     
  11. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    heres an idea... why not just shoot the projectile a bit faster? it wont fall as short as it is now... or hows about giving it a bit of a boost on its Z axis velocity when its spawned? that should make it arc a bit further.
     
  12. WheatPuppet

    WheatPuppet Corriganism

    Joined:
    Jan 22, 2002
    Messages:
    85
    Likes Received:
    0
    The problem with that is that I dont want to fire it faster. The flak shell moves horizontally at about the right rate, just it doesn't move vertically at the right rate. Trust me, I got the x/y movement about right.
     

Share This Page