Page 1 of 1

Problems with gun turret rotation..

Posted: Wed Jul 21, 2010 7:21 pm
by fo0k
So Im pretty sure I'm noobing this.. but I have a car.. with a gun on top..

Offline it works fine.. but when running server the gun will rotate 'so far' before springing/glitching back to a fairly random position.. opposite of where it got to..! Cant be more specific than that. but I want it to rotate endlessly left or right... except like I said.. it gets maybe 180 degrees then springs back.

Network info seems to be fine because other players can track the movement when slow. I guess the prob is the min max rotation. How 'should' I achieve this rather than these -9999 +9999 numbers.. ? Does it have to be a bundle like the sherman turret seperating x and y?

(The camera position is locked to the gun.. and like I said is perfect offline.)

Code: Select all

rem *** stratosCameraPassenger ***
ObjectTemplate.create Camera stratosCameraPassenger
rem ObjectTemplate.setMinRotation -9999/-6/0
rem ObjectTemplate.setMaxRotation 9999/6/0
ObjectTemplate.setPivotPosition -0.2/0/0
ObjectTemplate.setMaxSpeed 50/50/0
ObjectTemplate.setAcceleration 1000/1000/0
ObjectTemplate.setInputToYaw c_PIMouseLookX
ObjectTemplate.setInputToPitch c_PIMouseLookY

rem *** corvetteTurret ***
ObjectTemplate.create RotationalBundle corvetteTurret
ObjectTemplate.setNetworkableInfo corvetteTurretInfo
ObjectTemplate.setAttachToListener 1
ObjectTemplate.addTemplate corvette20mm
ObjectTemplate.setMinRotation -9999/-6/0
ObjectTemplate.setMaxRotation 9999/6/0
ObjectTemplate.setMaxSpeed 50/50/0
ObjectTemplate.setAcceleration 1000/1000/0
ObjectTemplate.setInputToYaw c_PIMouseLookX
ObjectTemplate.setInputToPitch c_PIMouseLookY

Re: Problems with gun turret rotation..

Posted: Wed Jul 21, 2010 7:38 pm
by Apache Thunder
Hmm so what you want is unlimited left/right movement?

If so you do not need to specify any numbers at all Just zero for that axis. Only max speed and acceleration and 0 for both min/max on X axis will do.

So for what you want to achieve for the bundle you wanted this on, here is the corrected code:

Code: Select all

ObjectTemplate.setMinRotation 0/-6/0
ObjectTemplate.setMaxRotation 0/6/0
ObjectTemplate.setMaxSpeed 50/50/0
ObjectTemplate.setAcceleration 1000/1000/0
(unlimited left/right movement with limited up/down movement)

The max speed/acceleration defined what axis it can rotate on and how fast it can go etc. The min/max rotation tells how far it can go. When both min/max is set to zero for rotation or the entire string left unspecified, this means unlimited rotation on that axis. 9999 is obviously invalid because there can only be up to 360 degrees of rotation. Basic geometry my dear Watson. :D

Also rem out everything else on your camera. If the camera is mounted to the gun it does not need to be allowed to move independent of the gun. This can cause problems even if the settings are the same as the rotational bundle. Since the camera has no network info, it's rotation might start to go out of sync with the gun's rotation. Just rem out everything on the camera so the camera is then frozen to point direction which is then determined by it's parent object, the gun turret. When you remmed out the min/max rotation settings on the camera you told the game to allow the camera to move in unlimited direction on the X and Y axis that your max speed and acceleration told it to. Hence why you need to rem out the control input settings and the max speed/acceleration setting for the camera.

If your camera wasn't addtemplated to the gun turret, it is recommended that you do that. That's how most vehicles with turrets and stuff do it. They rarely have the camera on it's own and rotate independent of a weapon turret. They almost always just addTemplate a stationary camera to the turret and the turret is what moves the camera. If there is an additional rotational bundle like a gun barrel (some tanks do this like the M1A1) then the camera goes on that instead.

For tank turrets there is usually two parts to the turret. The turret which only rotates left to right and then the gun barrel which only goes up/down. The turret moves the gun barrel and the gun barrel which is moved left to right by the turret also moves up and down and makes the camera attached to the gun barrel move left/right and up/down in sync with the turret and gun barrel. Having the camera addTemplated to the main bundle instead of the gun barrel which is then attached to the turret will most likely result in the camera going out of sync at some point during network play.

Re: Problems with gun turret rotation..

Posted: Wed Jul 21, 2010 8:21 pm
by fo0k
:)

awesome. thanks, will give this a spin!

..no pun intended

Re: Problems with gun turret rotation..

Posted: Wed Jul 21, 2010 9:09 pm
by fo0k
you done gone made it work.

I had thought previously that 0 would lock the rotation... but I got ya now ;)

Adding cam to gun was, I'm sure the thing that fixed it.
thanks man.

Re: Problems with gun turret rotation..

Posted: Wed Jul 21, 2010 11:28 pm
by Apache Thunder
Glad I could help. :D