I already have the starting Logic, but currently after that it just shoots straight up in the sky [right rocket]. The left Rocket only has the start logic and is slower.
Because the left on eshould follow a path I already created
for i = 0, numPoints do
local t = i / numPoints
local point = Bezier(t, modifiedStartPos, B, Target) -- a math function defined above
table.insert(curvePoints, point)
--Visualisation or maybe smt I need idk
local p = Instance.new("Attachment")
p.Name = "Attachment"..tostring(i)
p.Position = point
p.Parent = workspace
p.Visible = true
end
Now I want to apply the VectorForce or LinearVelocity, so that it flys to the next point.
I also added a AlignOrientation.
But at the moment I am not able to align the rocket right and get it so it wont go to high etc.
I also calculated the NukeMass, according to the workspace.Gravity. Thats the minimum Y Force we need to apply so it can fly.
Does anyone know how to get this alignOrientation and Vector Force to apply correctly?
I cant get the AlignmentOrientation to look at the correct angle.
Thanks for your help. If you need more informations just ask me.
Wouldn’t it be easier if you put the nodes into a folder then iterate on it?
local folder = game.Workspace.Folder -- this is the folder with parts that we will use as our nodes
for i, node in pairs(folder:GetChildren()) do
local p = Instance.new("Attachment", workspace)
p.Name = "Attachment"..tostring(i)
p.Position = node.Position
p.Visible = true
end
-- continue with your original script
Also can i see your entire script with the AlignOrientation and VectorForce logic? That would really help.
Yea, but it dosnt work. Just the takeof logic.
[When I created the Physical Attachements I only had a debug purpose in mind]
local Target = Nuke:GetAttribute("Target") -- Vektor 3
local startPos = Top.Position
local cruiseHigh = 600
-- 2. Point on the Bezier. Highes Point in the cruise
local modifiedStartPos = startPos + Vector3.new(0, 100 , 0)
local Bx = modifiedStartPos.X + 0.25 * (Target.X - modifiedStartPos.X)
local Bz = modifiedStartPos.Z + 0.25 * (Target.Z - modifiedStartPos.Z)
local B = Vector3.new(Bx, cruiseHigh, Bz)
local numPoints = 50
local curvePoints = {}
for i = 0, numPoints do
local t = i / numPoints
local point = Bezier(t, modifiedStartPos, B, Target)
table.insert(curvePoints, point)
local p = Instance.new("Attachment")
p.Name = "Attachment"..tostring(i)
p.Position = point
p.Parent = workspace
p.Visible = true
end
for i, child in ipairs(Nuke:GetChildren()) do
if child:IsA("BasePart") then
NukeMass += child.Mass
end
end
NukeMass = NukeMass * workspace.Gravity
local force = Instance.new("VectorForce")
force.Attachment0 = Instance.new("Attachment", Nuke.Engine)
force.RelativeTo = Enum.ActuatorRelativeTo.World
force.Force = Vector3.new(0,0,0)
force.Enabled = false
force.ApplyAtCenterOfMass = true
force.Parent = Nuke
local align = Instance.new("AlignOrientation")
align.Attachment0 = Instance.new("Attachment", Nuke.Top)
align.Attachment1 = workspace.Attachment1
align.RigidityEnabled = false
align.Responsiveness = 10
align.MaxTorque = math.huge
align.Parent = Nuke.Engine
align.Mode = Enum.OrientationAlignmentMode.TwoAttachment
--[[
align.CFrame = CFrame.fromMatrix(
Vector3.xAxis,
-Vector3.yAxis,
Vector3.zAxis
)]]
align.AlignType = Enum.AlignType.AllAxes
align.Enabled = true
[...]
Nuke.Engine.AssemblyLinearVelocity = Vector3.new(0,math.random(75,110),0)
task.wait(0.4)
force.Force = Vector3.new(0,NukeMass*1.01,0) -
force.Enabled = true
--Everything above working finde
--This down here
local direction = 0
local pitch = 0
--while true do
force.Force = Vector3.new(0,NukeMass*1,0) )
align.CFrame = CFrame.fromMatrix( --
--Not working in any way
)
I tried everything, changed the part down there like 20 times and experiemented while Playtesting. Nothing worked
local runService = game:GetService("RunService")
local points = --get points here
local i = 1
local a = 0
local startingPoint = points[i]
local goalPoint = points[i + 1]
local connection
connection = runService.Heartbeat:Connect(function(dt)
a += dt
if i > #points then
connection:Disconnect()
return
end
if a => 1 then
a = 0
index += 1
startingPoint = points[i]
goalPoint = points[i+1]
end
local targetCFrame = CFrame.new(startingPoint:lerp(goalPoint, a), goalPoint)
end)