Hello all, I am trying to make my own game, and I have run into a problem that I don’t seem to know how to solve, so hopefully one of you might know the solution:
So I am trying to use the SuggestProjectileVelocity
node to get the perfect shot speed for my basketball. I set up everything correctly to the best of my knowledge:
-
Start Location
: The spawn point of my ball. -
End Location
: A point on top of my hoop. -
Launch Speed
: Using a for loop to go through 1000 different launch speeds to find one that works. -
Override Gravity Z
: Set to 0 to use normal gravity. -
Trace Option
: None (won’t work if I put any other option in). -
Collision Radius
: My projectile’s radius. -
Favor High Arc
: True. -
Favor High Arc
: False
Now my problem is that my ball is not set up as a UE projectile but as an actor, and I’ve already changed some physics settings on it to stop it from going Mach 10 when I bump into it; mainly: mass
is set to 15 kg and Linear damping
is set to 0.3. angular damping
is 0.2 also, but I think it’s irrelevant.
And so the output velocity of my SuggestProjectileVelocity
is always undershooting, and I tested it without linear damping (or with it set to 0.01), and it worked perfectly, but again, my ball acts like a missile, and it is super twitchy when replicated, so I’d rather keep it on. I tried to compensate for it using the physics calculation way (i.e., using Newton’s second law applied to motion with velocity-proportional drag), resulting in:
v(t) = v0 e^(-D t)
v(t)
is the velocity at timet
v0
is the initial velocity
D
is the linear damping coefficient (as used in Unreal)
e
is Euler’s number (~2.718)
t
is time (Here time is calculated as Distance/Velocity)
But now my ball is overshooting by alot, everytime, so I figured damping is not calculated by the engine this way. SOOO IDK what to do. Plan B at this time is to disable damping while we shoot, then reenable it after a delay, but that breaks a mechanic in my game that I’d rather have. I don’t want it to be perfect, just close to it, but I need to know the perfect “theoretical” power of the shot.
Sorry for the longgg post, and thanks in advance.
Also any suggestion for Perfect Syncing of an actor like my ball with fast movement so its perfectly replicated across server and clients, other than what i did which is set its physics to only simulate on server.