yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 23 Mar 2015 12:16 PM |
How can i get a part(a turret) to rotate so the front of it is facing where it is about to shoot its raycast, if you need my raycast script just say
|
|
|
| Report Abuse |
|
|
|
| 23 Mar 2015 12:34 PM |
That is a complicated piece of work that Im not willing to give out for free. And I give out a lot of stuff.
1: Use BodyGyro
2: Fake the turret. Make it a circle. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 23 Mar 2015 12:44 PM |
| well that wasn't much help, can i not just get the angle from the turret to the ship and point it there? |
|
|
| Report Abuse |
|
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 23 Mar 2015 12:48 PM |
I would recommend not using BodyGyro and learning how to CFrame.
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 23 Mar 2015 12:49 PM |
local Player = game.Players.LocalPlayer local Character = Player.Character local Mouse = Player:GetMouse() local PlayerGui = Player:WaitForChild("PlayerGui")
local MAX_DISTANCE = 200
local rayFromShip = Character:FindFirstChild("HumanCarrier") or Character:FindFirstChild("HumanCorvette") or Character:FindFirstChild("Cruiser") or Character:FindFirstChild("Spider")
local rayFromPart = rayFromShip:FindFirstChild("Part")
local rayFrom = rayFromPart:FindFirstChild("Turret")
--while wait(1) do Mouse.KeyDown:connect(function(Key) if Key == "f" then local target = nil local dist = MAX_DISTANCE for _,v in pairs(game.Workspace:GetChildren()) do local foundShip = v:FindFirstChild("HumanCarrier") or v:FindFirstChild("HumanCorvette") or v:FindFirstChild("Cruiser") or v:FindFirstChild("Spider") if foundShip ~= nil and foundShip ~= rayFromShip then
local mag = (rayFrom.Position - foundShip.Position).magnitude if mag < dist then target = foundShip dist = mag end end end if target ~= nil then local magnitude = (rayFrom.Position - target.Position) local ray = Ray.new(rayFrom.Position, (target.Position - rayFrom.Position)) local hit, position = game.Workspace:FindPartOnRay(ray, rayFrom) local humanoid = hit:FindFirstChild("Health") if humanoid then if hit:FindFirstChild("Health").Value >0 then humanoid.Value = humanoid.Value -10 end end local distance = (position - rayFrom.Position).magnitude local rayPart = Instance.new("Part", game.Workspace) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright red") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position,rayFrom.Position) * CFrame.new(0, 0, -distance/2) --add it to debris so it disappears after 0.1 seconds game.Debris:AddItem(rayPart, 0.1) end end end) --end
while wait(0.1) do local rayFrom = Character:FindFirstChild("HumanCarrier") or Character:FindFirstChild("HumanCorvette") or Character:FindFirstChild("Cruiser") or Character:FindFirstChild("Spider") for _,v in pairs(game.Workspace:GetChildren()) do local foundShip = v:FindFirstChild("HumanCarrier") or v:FindFirstChild("HumanCorvette") or v:FindFirstChild("Cruiser") or v:FindFirstChild("Spider")
if foundShip ~= nil and foundShip ~= rayFrom then local mag = (rayFrom.Position - foundShip.Position).magnitude if mag <= 200 then PlayerGui.Target.Frame.Visible = true PlayerGui.Target.Frame:TweenPosition(UDim2.new(0.2, 0, 0, 0), "In", "Linear", 1) else if mag > 200 then print("Too Far") PlayerGui.Target.Frame:TweenPosition(UDim2.new(0.2, 0, -1, 0), "In", "Linear", 1) PlayerGui.Target.Frame.Visible = false end end end end end
There is the script, where would i add so the turret faces |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 09:56 AM |
| If the turret is welded and you plan on making the turret face a point while welded, good luck. Until I properly learn CFrame, even I wont be able to do that. |
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 24 Mar 2015 10:51 AM |
Lol or you could weld everything possible
Put a part on the barrel. Make that part of the bodyposition of the nearest player or whatever
make the base of the turret have a hinge
bam |
|
|
| Report Abuse |
|
|