DHProjectileFire's SpawnProjectile() function seems to be duplicating damage done by the actual bullet??

Issue #291 invalid
Matt Hands created an issue

Am I misreading this? Seems really FUBAR !

DHBullet handles hit detection, damage & effects. It is replicated to all clients & they then simulate the flight patch and hit detection of the real, definitive version on the server. The clientside bullet is just to calculate and spawn hit effects. The server bullet handles definitive hit detection and deals out any damage.

SpawnProjectile() in a vehicle MG just spawns the projectile, either tracer or normal, as it should. Hit detection, effects & damage are left to the bullet actor, on server & clients.

What is SpawnProjectile() in a small arms weapon fire class doing trying to detect hits (serverside) & calling TakeDamage()??

Am I missing or misreading something? Looks to me like this all this needs removing.

Any thoughts or insight very welcome. Cheers.

Comments (2)

  1. Matt Hands reporter

    Figured it out ! It's an optimisation, mostly for the network.

    The pre-launch trace checks if bullet is going to hit something pretty close - within 43m. At that range, ballistics & target lead are negligible. So instead of spawning an invisible bullet actor, that will have to be replicated to all relevant clients, the server decides that it hit the close-range target anyway & to skip spawning the bullet. Server sets some replicated variables on the replicated 3rd person weapon attachment actor, which clients can then use to show hit effects.

    I think the other advantage is that network delays in replication can mean the projectile actor only gets replicated to clients after it has travelled some distance (on the server). And if the target/hit actor is really close, the clientside projectile may spawn the other side of the target, meaning no hit effects or misleading effects. Think there's merit in doing a similar pre-launch trace and intervention for shells too, as they often seem to pass through close range targets clientside, although the server registers the real hit and damage.

  2. Log in to comment