I am looking for a way to use CFrame to the Velocity property of LinearVelocity. I want whoever I hit with a punch to slowly be knocked in front of the player. So far reversing look vector does work but it does not work as well when the opponent is on your left or right
What i am using(Does not work as well)
Velocity.VectorVelocity = -(Character.HumanoidRootPart.CFrame.lookVector * 10)
What I tried but did not work(What i need)
local position = Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 5)
Velocity.VectorVelocity = position.p
The main issue I identified is .p just does not seem to work for velocities
04nv
(04nv)
July 11, 2022, 4:56pm
2
I’m thinking maybe you just have to set the Actuator.
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
LinearVelocity.VectorVelocity = position.p -- Make sure you parent it!
I don’t fully know the behavior of this new object but I’m thinking that’s what’s needed first.
If position
is a CFrame, use position.Position
instead.
Oh yeah and make sure you parent it.
Okay, I’ll try this out thanks! I’ll make sure to mark it if it works
It seems to just be going in the same direction, I’ll show the full code regarding linearvelocity
local Velocity = Instance.new("LinearVelocity")
Velocity.Parent = Character.HumanoidRootPart
Velocity.MaxForce = math.huge
Velocity.Attachment0 = Target.HumanoidRootPart.RootRigAttachment
local lookpos = Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 5)
Velocity.RelativeTo = Enum.ActuatorRelativeTo.World
Velocity.VectorVelocity = lookpos.Position
04nv
(04nv)
July 11, 2022, 5:04pm
5
I think you’ll have to update it as time continues on. Make a loop or a temporary connection to update the lookpos variable.
Before i do that im gonna try using the X Y Z variables of the cframe separatly
and it looks like nothing seems to work
04nv
(04nv)
July 12, 2022, 10:13pm
8
I expected that, unfortunately. Though, I’d also try to manually set the velocity which seems to do just as good.
BasePart.AssemblyLinearVelocity = Vector3.new(X, Y, Z)