Silly Flak Grenade Physics

  • 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.
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.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
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)
 

EasyRaider

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
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:

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Originally posted by EasyrideR_/\
That code would be frame rate dependant.

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.
 

EasyRaider

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
Originally posted by Wormbo
Acceleration won't do anything because Physics is set to PHYS_Falling.
I didn't know that. But you wouldn't want PHYS_Falling when you're doing your own gravity anyway.
 

EasyRaider

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
You mean the native physics code makes less massive objects fall slower? :eek: I refuse to believe the physics are that bad coded...
 

EvilDrWong

Every line of code elevates you
Jun 16, 2001
932
0
0
40
Inside the machine
Visit site
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.