Hi everyone, I have a bit of a bizarre issue. Often when using the weapon trajectory mode Muzzle to Look Target, the bullet flies in a different direction than at the look target. Often the bullets fly at the camera. I am not certain of the exact cause but there are patterns as to when it happens. (Every time I think I have it nailed down it turns out to be wrong.)
The main factors appear to be the location of the player character relative to the weapon, the direction in which the player is aiming, and whether the character is occluded from the camera or if the camera is not completely free to move (up against a wall or such). I am using the community content Marble Control by WaveParadigm, which effectively replaces the character with a marble. What happens internally is that the character is made invisible and then offset from the position of a spawned physics sphere, typically -10000 units on the Z axis. Marble Control then handles movement input. When the character is offset by a very small distance, for example +100 units, this bug never occurs. When the player is offset by a large distance, for example -10000, the bug occurs almost constantly.
Past a certain distance the magnitude does not seem to matter. Negative offsets are convenient here because the character is almost always occluded by a floor. The opposite can work, just with a ceiling or a wall; this actually makes it more obvious as moving under an object immediately changes the behavior of bullets.
I spawn weapons and have one follow each player's marble. The shoot and reload abilities are not contained within each weapon but are in a separate equipment object; that equipment is equipped by the player, and the weapon is not equipped. The weapon references those shoot and reload abilities via its attack/reload ability properties. This is done so that the weapon is not attached to the player character.
The Z component of the camera orientation has a significant effect. When it is in the opposite direction of the offset, and the magnitude is significant (e.g. aiming 30 degrees above the horizontal with a -10000 offset) the bullets fire toward the camera. This doesn't happen if the camera is free and the character is not occluded. When the player fires at or somewhat above the horizontal, the bullets go in the correct direction. When the Z component is in the same direction of the offset, the bullet goes lower than the crosshair from the perspective of the camera (regardless of whether the offset is positive or negative).
This is a pretty weird one, I suspect the only way to figure out the solution is to delve into exactly how this trajectory mode works and that might not be possible.
On a side note - do the weapon trajectory modes calculate trajectories based on where the client was aiming when the player activated the shoot ability, or is it based on what the server last saw?
Thanks for looking! Any insight would be incredibly appreciated.