Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#769 closed defect (fixed)

[PATCH] Projectiles occasionally bounce

Reported by: Philip Taylor Owned by: Markus
Priority: Nice to Have Milestone: Alpha 14
Component: Core engine Keywords: patch
Cc: Patch:

Description

It looks like projectiles randomly sometimes bounce when landing, which they're not meant to do. (Presumably some precision bug in the projectile motion code.)

Attachments (1)

new-projectile-calculation.patch (4.8 KB ) - added by Markus 11 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Kieran P, 13 years ago

Milestone: Alpha 5Backlog

comment:2 by Markus, 11 years ago

In CCmpProjectileManager.cpp:212 (CCmpProjectileManager::AdvanceProjectile) we decrease timeLeft from a positive value over zero to a negative value. And we divide by it in line 234 :

float vh = (projectile.gravity / 2.f) * projectile.timeLeft + offset.Y / projectile.timeLeft;

If projectile.timeLeft is reasonable small (negative and close to zero) vh will first bounce up again.

This problem can also corrupt the x and z coordinates.

One simple solution could be to set the projectiles postion to the targets position for a small timeLeft. (The flight would not continue as no delta could be calculated.)

Last edited 11 years ago by Markus (previous) (diff)

comment:3 by zweigousefen, 11 years ago

In a recent match with Alpha 13 from the debian repos, my bolt shooters were shooting up in the air when asked to attack a building (they were shooting properly at units when auto defending a zone, but I haven't investigated further). It could be related, as the missiles go upwards like when they bounce, but they do it when they're launched. The target wasn't impacted, so the bug is not only graphical.

See screenshot : https://www.rhizogen.es/~ac/vrac/boltshooterbug06.png

comment:4 by Markus, 11 years ago

The quoted formular above will not converge correctly for bigger dt. (The lags (and so dt) can get near the time of the whole flight.)

The more correct solution seems to always calculate the "whole flight" and not incrementally. The other problem is if dt is too big, the projectile is in one step in front of the target and in the next step already behind/below it.

by Markus, 11 years ago

comment:5 by Markus, 11 years ago

Keywords: patch review added
Summary: Projectiles occasionally bounce[PATCH] Projectiles occasionally bounce

The new calculation should prevent bounces or wrong positions during flight due to big lags.

The damage is done with a timer. It should work regardless of the lag or graphical calculation. (I only noticed a time difference between the hit and the damage is taken. That will let the projectile fly through the target and then suddenly vanish behind it. This behaviour already existed before.)

comment:6 by historic_bruno, 11 years ago

Milestone: BacklogAlpha 14

comment:7 by historic_bruno, 11 years ago

Did you test if this fixes the originally reported bug? If so, is there an easy way to test that? :)

comment:8 by Markus, 11 years ago

I had no test, just played and havent noticed it anymore.

(The problem zweigousefen reported is easily reproduced in a game with a big lag, the cosmetic part is fixed.)

comment:9 by historic_bruno, 11 years ago

Owner: set to Markus

comment:10 by sanderd17, 11 years ago

Resolution: fixed
Status: newclosed

In 13664:

fix bouncing projectiles, patch by Markus. Fixes #769

comment:11 by sanderd17, 11 years ago

Keywords: review removed

comment:12 by sanderd17, 11 years ago

Thanks for the patch, it works as advertised.

Note: See TracTickets for help on using tickets.