demoinfo
demoinfo copied to clipboard
Nade Trajectory
Is it possible to grab the grenade trajectory from point where it is fired to the point where it explodes?
Yes, it's possible, though not through the public API. Each grenade has an associated projectile entity that you can track in the air. HEs and flashes are both CBaseCSGrenadeProjectile
, molotovs and incendiaries use CMolotovProjectile
and the others use CSmokeGrenadeProjectile
CDecoyProjectile
. You can track their positions using the Cell
properties. If you want to see an implementation, look here: https://github.com/econoraptor/demoinfo/tree/DetonateInterpolate2
At a minimum you'll need to subscribe to the properties and use SetCellWidth
and CellsToCoords
to map the Cell values to normal position values.
We'd be open to a PR that opens the grenade-projectiles up via the API.
@econoraptor thanks for the explanation, I've been trying to track their trajectory using grenades velocity, angle, position at the throw moment but I think the cell strategy is more bullet proof.
@thiagofelix That method might have worked for demos where the snapshotrate matched the tickrate, but it would have been fairly inaccurate for all other demos.
@moritzuehling you'r right, just tried out using the cells and it worked like a charm =) thank you so much.
I am building a replay viewer that parses the demo in the browser itself on user's computer, sort of standalone app without need of a server, so far got everything I wanted working (player's position, nades, memory consumption acceptable)
Thanks again for the help