UE3 - UT3 PHYS_Falling canvas.project?

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

sithlegend

New Member
Jun 26, 2004
18
0
0
how do you canvas.project...
a projectile that has Physics=PHYS_Falling
and terminal velocity?

i want to project on my screen where a projectile is going to land
not from the projectile side cause the projectile has not spawned
i want to project it on vehicle side, a tank

this is how i project on a flying projectile
what do i need to account for gravity and terminal velocity?
Code:
GetFireStartLocationAndRotation(SocketLocation, SocketRotation);
    RealAimPoint = SocketLocation + Vector(SocketRotation) * vsize(socketlocation-lockedtarget.location);
    RealAimPoint = Hud.Canvas.Project(RealAimPoint);
 
Last edited:

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Accounting for gravity (or any acceleration in general) is easy: TargetLocation = FireLocation + InitialVelocity * FlightTime + 0.25 * Gravity * Square(FlightTime)
(Yes, that's 0.25, not 0.5 as you might expect. The engine is a bit weird here...)
To extend that calculation with TerminalVelocity, you need to break it down into smaller steps, each time applying (half?) gravity/acceleration to velocity, limiting velocity and then applying velocity to location. To figure out ground contact, you can use a fixed time step instead of calculating and dividing the flight time. Then do a trace from the current calculated location to the next calculated location and at some point you (hopefully) hit world geometry. This is where the projectile would likely impact. You will need to find a good balance between speed (number of traces, less is better) and accuracy (step delta time, smaller is better). For example, the UT2004 SPMA uses a 0.3 seconds delta time for its target predictions. That level of precision is required for a steep shot, but for shots with and angle of elevation less than 45° you can probably use larger delta times.
 
Last edited:

sithlegend

New Member
Jun 26, 2004
18
0
0
thanks wormbo
i would use a projectile with out terminal velocity
like you suggested to me one time
but setting my terminal velocity to zero just makes my projectile go flat on the ground
i don't think its possible on ut3 to spawn a projectile with out terminal velocity when its physics are set to falling
i check the projectile classes and they have terminal velocity on default to 3000 or something like that

unless i missed something where i can discard the terminal velocity from my projectile
 
Last edited:

sithlegend

New Member
Jun 26, 2004
18
0
0
is this final?

any of this correct for initial velocity?

for projectile speed i have 15000 and max speed is 15000 i don't use acceleration terminal velocity i set it to 15000 as well
btw i don't know if i forgot to mention, but , i want to know where it will land before i shoot my projectile
not after it has been launched, that's why i cant take the velocity straight from my projectile, because it does not exist yet

Code:
InitialVelocity=socketLocation * Vector(SocketRotation) * Projectile.Speed;
InitialVelocity=socketLocation + Vector(SocketRotation) * Projectile.Speed;
InitialVelocity=socketLocation * Vector(SocketRotation) * Projectile.Time of flight;
InitialVelocity=socketLocation + Vector(SocketRotation) * distance_to_target;


is this the final?
Code:
GetFireStartLocationAndRotation(SocketLocation, SocketRotation);
InitialVelocity=socketLocation * Vector(SocketRotation) * Projectile_Speed;
TimeOfFlight =VSize(lockedtarget.location - SocketLocation) / Projectile_Speed; 
TargetLocation = socketLocation + InitialVelocity * TimeOfFlight + 0.25 *WorldInfo.WorldGravityZ * (TimeOfFlight * TimeOfFlight);
 
Last edited:

sithlegend

New Member
Jun 26, 2004
18
0
0
oh i see, yeah i guess it does not matter where the velocity starts
its just direction + speed

ok so velocity is?

Vector(SocketRotation) * Projectile_Speed

ok so i did it like this and sorta works
Code:
RealAimPoint = SocketLocation + InitialVelocity * ProjectileTimeA+(vect(0,0,0.25)*WorldInfo.WorldGravityZ)* (ProjectileTimeA*ProjectileTimeA);

my projectile is landing a bit short
i think its cause for time of flight i am using distance/speed so i need to calculate TOF using gravity
 
Last edited: