Tanker273
|
  |
| Joined: 25 Mar 2011 |
| Total Posts: 57 |
|
|
| 05 Apr 2015 06:26 PM |
I am trying to build some tanks and stuff (which has gone well) but I am trying to get a code to rotate the turret head (which freely rotates w/ welded gun to it) and I can't get anything to work. I've had a code get the X, Y and Z or Mouse.Origin and plug those numbers into a BodyVelocity, BodyGyro and several others inside the central turret part, but nothing works. Can anyone help?
BTW, this was the code mentioned above (As a local script in the player's backpack) (I know it's probably a mess):
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.Button1Down:connect(function() print("Button 1 is down") print(Mouse.Origin) game.Workspace.AMX_50b.Turret.WeldToTurret.TurretHeadUnion.BodyGyro.cframe = Vector3.new(Mouse.Origin.X, Mouse.Origin.Y, Mouse.Origin.Z) end
P.S, as I said, it plugs in the numbers fine, but the closest I got was a BodyGyro only rotating the turret head to (0, 0, 0), with no change in sight.
P.S.S, If you wanted to see said tank, here it is: http://www.roblox.com/AMX-50b-No-working-gun-yet-item?id=234322263 |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 06:41 PM |
| game.Workspace.AMX_50b.Turret.WeldToTurret.TurretHeadUnion.BodyGyro.cframe = CFrame.new(workspace.AMX_50b.Turret.WeldToTurret.TurretHeadUnion.Position, Mouse.Hit.p) |
|
|
| Report Abuse |
|
|
Tanker273
|
  |
| Joined: 25 Mar 2011 |
| Total Posts: 57 |
|
|
| 05 Apr 2015 06:53 PM |
| This does work, in a sense. It attempts to move the turret, but just thrusts it in the given direction as opposed to rotating in said direction. I just tried to play with it a bit, moving the desired rotating part to the muzzle at the end of the barrel, but now the barrel swings wildly, and I might be able to fix it, but the current mesh I am using for the muzzle, it dictates a need for a specific rotation, which doesn't agree with the new positions added to the bodygyro. |
|
|
| Report Abuse |
|
|
Tanker273
|
  |
| Joined: 25 Mar 2011 |
| Total Posts: 57 |
|
|
| 05 Apr 2015 07:14 PM |
| I actually may have just got it working. It is still very glitched and jittery, and does not like to aim up, but I played whit the code a bit and had to edit the tank model itself so the turret part this script was operating off of was facing forward, not left. Thanks for the help. |
|
|
| Report Abuse |
|
|