So i’m using a BodyPosition to make an object go to where it was previously (i have another script that changes maxforce).
After debugging while playtesting I found out that the position property on the BodyPosition wasn’t being updated. I’m relatively new to scripting and this is probably a small issue which I’m overlooking. I’m not getting any errors so I don’t know where to start.
Thank You to whoever shines light on the issue.
local bodypos = script.Parent.BodyPosition
local pos = script.Parent.Position
while true do
bodypos.Position = Vector3.new(pos.X,10,pos.Z)
wait(0.1)
end
local bodypos = script.Parent.BodyPosition
bodypos.Parent = script.Parent
local pos = script.Parent.Position
bodypos.Position = Vector3.new(pos.X,10,pos.Z)
--Just do this
Also why are you making it in a loop? SInce adding a loop wont change it’s value the value is always gonna be the same pos.X,10,pos.Z no changes
It’s what im using for a spaceship to get the position and use it to dampen steering and movement. So i need a constant feed of location for the bodyposition. Is there a better way to do so? I will add some calculations so that it doesnt snap back a bit
I am not that experienced with them but you can use BodyVelocity just make sure all the spaceship parts are connected with WeldContraints and are not anchored and then do this
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Parent = --PathToTheMainPart
--// Make sure to make the MainPart's front face to be looking up
bodyVelocity.Velocity = --PathToTheMainPart.LookVector * amount
bodyVelocity.Velocity = Vector3.new(math.huge,math.huge,math.huge)
The current system I have uses 3 scripts:
One controls 2 bodythrusts,
One controls Max force for the bodyposition
One is a feed for the bodyposition.
Since the ship moves linearly through a level, The axis is locked automaitcally using a bodygyro and steering is just moving left and right. The bodythrusts are for acceleration and deceleration, and steering. The Bodyposition is used to dampen these movements when they are not held since there isnt any friction in air and things just fly off. so e.g. when steerfloat is not 0 therefore maxforce.X is 0 and vice versa. So forces don’t have to fight