He literally wants to create a tracking sustem
Again, CFrame
is the only thing I can think of right now. Or maybe other physics constraints which you can take a look of it here.
I know. My answer may not be clear but if you read and understand how CFrame
works, then my answer could work. How about you share us your idea here?
Im not saying you should create one (that’d be nice tho), im asking how would I make one…
So, one of the steps is having a “lookat” cframe, so from the base of the Missile position and then the Part Position. You’d need to have it on a loop or detect if the part has changed position.
I’m not a professional scripter so I’m not really sure how, sorry maybe you could look for how real rockets work and recreate that in studio? Here’s how they do
Also do you want the system to be 100% accurate or have a error margin? If it’s the second I would create a part that is at the coordinates of the HumaniidRootPart that is way bigger than the player and make the missile go in any place of the part
So, I did a small script. Is this how you would want it? Though It’s best to not use tweens as the speed increases if the Target is Far.
that looks great, it could use a bit of tinkering but thats very nice, can I have it?
Sure, here you go.
local TS = game:GetService("TweenService")
local S = game.Workspace.Start
local E = game.Workspace.End
local F = game.Workspace.Follow
F.Position = S.Position
game:GetService("RunService").Heartbeat:Connect(function()
F.CFrame = CFrame.new(F.Position, E.Position)
end)
E:GetPropertyChangedSignal("Position"):Connect(function()
TS:Create(F, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Position = E.Position}):Play()
end)
is there a way to make the part orient itself towards the end part?
This code has a number of issues:
- Tweens are not best to used in this scenario. I think it can be performance heavy as you are creating a new tween every time the target moves.
- If the missile or part is close to the target, notice that it moves slowly. The missile should move with a constant speed.
@BreezeOnTheDoor if you want the part to orient itself towards the target, then you need to use CFrame
or any other physics constraints.
do you know how I could do it then?
Yeah, I know. I literally just said that when I was sending the script.
The best way is to use physics. You could skip all the CFrame nonsense unless you want to be precise. Use align position and align orientation, update them every frame.
the thing is idk how I would actually make it track… and like I said, I got barely any experience with physics and stuff… so do you know a way I could track it with those?
I am not going to give you a direct solution to your problem, but I could give my two cents on how to approach this goal. I recommend read this tutorial about understanding CFrames at a basic level so you know what functions to use in this scenario.
If you really wanted to use CFrames, you should do this every frame:
- Find magnitude between missile and tracker
- Set CFrame so every frame the magnitude is slowly reduced
- use CFrame.lookat() to orient the tracker
But what you should do is use:
alr, but im wondering how I should use those physics stuff to track? like where would I start? How would I fill out those parameters