Hello! I came here because I have been having issues trying to rotate a knife based on the direction that it is traveling in. I have created a script that allows the player to throw a knife towards the direction of their mouse, however I need the knife to rotate towards the direction that the knife is traveling.
knifeDummy.Velocity = CFrame.new(player.Character.HumanoidRootPart.Position, mousePos).lookVector * 2
Above is the code that I used to make the knife travel towards the mouse using the mouse hit position and lookVector. How would I go about making the knife rotate towards the direction of the velocity?
Note: I have tried to use AngularVelocity but the knife rotates towards the same direction every time, despite me throwing the knife in a different direction.
With some help from @killerbrenden I came up with a solution.
knifeClone.BodyForce.Force = Vector3.new(0, knifeClone:GetMass() * workspace.Gravity, 0) --This creates a BodyForce that will counter gravity, essentially preventing the knife from falling. knifeClone.Velocity = CFrame.new(player.Character.HumanoidRootPart.Position, MousePos).lookVector * 175 * windupMultiplier --This makes the knife throw towards your mouse. The speed is multiplied by windupMultiplier, which is a value that changes based on how long you pulled back the knife before throwing it. knifeClone.CFrame = CFrame.new(handle.CFrame.p,MousePos) --This sets the initial position of the knife. knifeClone.RotVelocity = knifeClone.CFrame:vectorToWorldSpace(Vector3.new(-15, 0, 0)) --[[THIS IS THE ANSWER TO THE QUESTION This will rotate the knife at a constant rate towards the direction that the knife is going.]]--