I am working on thor’s hammer wherein the idea is simple, you throw the hammer by left clicking and summon it back by right clicking. I have completed the throw part however I have a problem making the summoning of the hammer work harmoniously.
Excerpt:
if State == "Throw" then
local BodyVelocity = Instance.new("BodyVelocity",Mjolnir)
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.velocity = Direction.LookVector * Speed
elseif State == "Retrieve" then
-- Retrieve funcion
Mjolnir.Parent = Character
local BodyVelocity = Mjolnir.BodyVelocity
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity.Velocity = RightHand.CFrame.LookVector * 100
The Result:
https://streamable.com/e2wz2f
The throw works but the return doesn’t. My idea is to have the hammer travel infinitely(Assuming that is possible and it doesn’t get destroyed after travelling a certain distance) once thrown and when the player clicks the right mousebutton, it’ll return by travelling back. I used bodyvelocity for the throw part and bodyposiition for the summon but that didn’t work, I figured it was because of the existing bodyvelocity in the part. I then switched both to body velocity and using the same bodyvelocity, thinking that the problem was because a new bodyvelocity would be unable to override the existing one but that didn’t work either.
How can I make it so that the same hammer would come travelling back to the character, would I have to use raycasting?