Re: Gunfire off center from crosshair.
Posted: Sun Aug 30, 2015 10:19 pm
The slippage may be that the camera is not near the center of mass of the turret, so from certain directions, projectiles seem to fire further off from what you intended. There are two ways to fix this. First, you could simply attach the camera to the turret and move the camera forward/down/up until the turret mesh no longer obstructs your view (I would suggest you go with this option). Second you can try moving the camera so that it's near the center of mass for the turret. (it can still be off by one axis. On the vertial axis you can have it a few meters above the turret (or below) depending on where you currently have the camera)
The best fix is to simply make the camera stationary and attach it as a child object to the turret with the gun. You may have to tweak the position to prevent meshes from blocking your view, but currently it's the only surefire way of resolving your issue. I generally avoid having the camera move on it's own with setups like this in my mods as it will inevitably result in the issues you mentioned.. It can become a bigger problem in multiplayer too. I haven't tried this, but you can also try adding network info to the camera object. This should ensure it will move at the same rate as the turret (which should also have network info by the way) in multiplayer. Adding network code to the camera object is a last resort. I highly recommend you just make the camera a child object of the turret. (remove the rotation/speed code from your camera afterwords. You don't have to set them to zero. Just remove all the commands for movement like setPosition, setRotation, setAcceleration, etc. These commands are zero by default if you leave them undefined so no need to specify them with zeros. )
If you end up making it a stationary camera that is a child object of the turret, you won't need to add network code to the camera FYI. The turret moves the camera for you and the turret should already have netcode on it. You can offset the camera on any axis you like. It will offset the fire direction a little depending on how far you have to offset it (but small changes within a meter or so shouldn't cause issue for aiming), but at least the aim will always be consistent no matter where you aim at.
The best fix is to simply make the camera stationary and attach it as a child object to the turret with the gun. You may have to tweak the position to prevent meshes from blocking your view, but currently it's the only surefire way of resolving your issue. I generally avoid having the camera move on it's own with setups like this in my mods as it will inevitably result in the issues you mentioned.. It can become a bigger problem in multiplayer too. I haven't tried this, but you can also try adding network info to the camera object. This should ensure it will move at the same rate as the turret (which should also have network info by the way) in multiplayer. Adding network code to the camera object is a last resort. I highly recommend you just make the camera a child object of the turret. (remove the rotation/speed code from your camera afterwords. You don't have to set them to zero. Just remove all the commands for movement like setPosition, setRotation, setAcceleration, etc. These commands are zero by default if you leave them undefined so no need to specify them with zeros. )
If you end up making it a stationary camera that is a child object of the turret, you won't need to add network code to the camera FYI. The turret moves the camera for you and the turret should already have netcode on it. You can offset the camera on any axis you like. It will offset the fire direction a little depending on how far you have to offset it (but small changes within a meter or so shouldn't cause issue for aiming), but at least the aim will always be consistent no matter where you aim at.