I have a missile truck thing
and when a target is selected, I want the missile shooter to turn toward the target. I could probably use CFrame.LookAt but I don’t know how I would do it smoothly…
here is my workspace:
I have a missile truck thing
Perhaps this post would help
hey, this looks good but I don’t really want a while true or something. Is there a way that I could incorporate LookVector and turn it until it reaches the desired position?
maybe add a motor6d and lerp it to the mouse hit position
its not really the position, its the orientation of it… I don’t really know much about lerps and motor6D so if you could give examples/help out that’d be great but thx for the idea
you can tween the model to the mouse by creating a cframe value and setting that cframe to the model with pivotTo().
this is what i mean.
local runService = game:GetService("RunService")
local players = game:GetService("Players")
local tweenService = game:GetService("TweenService")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local turret = game.Workspace:WaitForChild("Turret") -- change this to your model path
local CFrameValue = Instance.new("CFrameValue")
local function tweenTurret()
local turretCFrame = CFrame.lookAt(Vector3.new(turret:GetPivot()), mouse.Hit.Position)
local tweenInfo = TweenInfo.new(1)
local tweenGoals = {Value = turretCFrame}
local tweenResult = tweenService:Create(CFrameValue, tweenInfo, tweenGoals)
tweenResult:Play()
end
CFrameValue.Changed:Connect(function()
turret:PivotTo(CFrameValue.Value)
end)
mouse.Button1Down:Connect(tweenTurret)
you can use tween service
Char LIMIT AHAHAHAHAAA
i had that idea too, but it was too simple and kinda uhh, clear
well, it doesn’t really work…
local function aimTurret(target)
local tweenService = game:GetService("TweenService")
local turret = script.Parent.Parent.Gun -- change this to your model path
local CFrameValue = Instance.new("CFrameValue")
local function tweenTurret()
local turretCFrame = CFrame.lookAt(Vector3.new(turret:GetPivot()), target)
local tweenInfo = TweenInfo.new(1)
local tweenGoals = {Value = turretCFrame}
local tweenResult = tweenService:Create(CFrameValue, tweenInfo, tweenGoals)
tweenResult:Play()
end
tweenTurret()
CFrameValue.Changed:Connect(function()
print(CFrameValue)
turret:PivotTo(CFrameValue.Value)
end)
end
EDIT: if it was too fast, I entered the coordinates, launched, and it tweened the whole thing far away
@aron01224
pov: cframe value set to 0,0,0
pov: tween changed CFrame value
nvm bruhh14211e1d2d12 where is the script parented to
Nobody needs your place file, I recommend you delete it to avoid anyone stealing it.
alr, but none of the assets (models for testing) are mine and none of the code even works
where is the script parented to!1!!!
oops ill send it one sec
its the one under MainController
why is that so far away xd
idk… because it is? You could just do “play here”
bruh bro.wmv (560.1 KB)
its only for client, but i know a way to make it for the servr (no it didn’t work yet)