Ive been stuck on this for a while ,any help is appreciated alot
im trying to make a drone; its moved by vectorforces
if MovementTable[keyPressed.Name] and not applyingForces[keyPressed.Name] then
local archive = keyPressed
--table.insert(applyingForces, keyPressed.Name)
applyingForces[keyPressed.Name] = MovementTable[keyPressed.Name]
vectorForce.Force += MovementTable[keyPressed.Name] * DronePM:GetMass() * 6
--DronePM.AssemblyLinearVelocity += MovementTable[keyPressed.Name] * DronePM:GetMass() * .2
while task.wait(.1) do
if not uis:IsKeyDown(archive) then
vectorForce.Force -= MovementTable[archive.Name] * DronePM:GetMass() * 6
im trying to dampen the speed of the direction the vectorforce was moving it in
it works how i want when i only move in a single positive direction(only right or up or forward)
but when i move in a -vector direction, it starts to bounce and stop abruptly unlike the positive direction
and when i try to stop while holding down two directions, it completely stops the drone in all directions
this is what i have in total for the movement and dampening function
while task.wait(.1) do
if not uis:IsKeyDown(archive) then
vectorForce.Force -= MovementTable[archive.Name] * DronePM:GetMass() * 6
applyingForces[archive.Name] = nil
local damperAmount = .1
local x1,y1,z1 = 0,0,0
local archiveVector3 = MovementTable[archive.Name]
--print(archiveVector3)
local secondaryAxis
for _, v in MovementTable do
if applyingForces[archive.Name] and v == -applyingForces[archive.Name] then
secondaryAxis = v
end
end
local taskvariable
while task.wait(.1) do
if applyingForces[archive.Name] then
print("break1") break
end
local wished = DronePM.AssemblyLinearVelocity * archiveVector3
print(wished, wished.Magnitude)
DronePM.AssemblyLinearVelocity = wished * damperAmount
if wished.Magnitude <= .2 then
print("killed by speed") break
end
end
break
end
this is the movementTable thats being referenced in the function
local MovementTable = {
["W"] = Vector3.new(0,0,-6),
["D"] = Vector3.new(6,0,0),
["A"] = Vector3.new(-6,0,0),
["S"] = Vector3.new(0,0,6),
["E"] = Vector3.new(0,6,0),
["Q"] = Vector3.new(0,-6,0)
}
i want to basically only slow down the direction that no longer has force on, for example; if i let go of the D key, i’d want the velocity to dampen the -x value only (since it was moving left) and leave the rest of the vector3 the same
same thing for if i had the W and D let go but still holding the S key, i’d only wanted the +Z and -X value damped and the S key (+X value) left the same
let me know if i need to describe or add more
thanks