Rotate a projectile based on mouse position

Basically, I’m making a bow that shoots an arrow towards the direction of the mouse when activated. I was able to accomplish this. However, the orientation of the arrow is based on the character’s HumanoidRootPart orientation, which makes it strange when shooting. The question is, how do I make the arrow rotate based on the destined point (mouse.hit.p)?

Gif:
https://gyazo.com/38269b15e345e93f5031d1d8401f5195

1 Like

Make sure the arrow is using the HumanoidRootPart Cframe when it is shot. Iirc the HumanoidRootPart does not have a fixed orientation and rotates depending where the player is facing.

Yea, it uses the humanoidrootpart cframe when shot. I don’t think I was specific enough sorry. Heres the issue:
https://gyazo.com/38269b15e345e93f5031d1d8401f5195

Oh now I understood your question. Hm, are you creating a ray when shooting the arrow?

Im not sure but this thread might help : Wrote up a short script to get 3D mouse hit from UserInputService

From what I read from the post, It seems like it only returns the position of the mouse? I’m looking for orientation wise.

If the front face of the object is actually the intended direction when your using it then you could use the CFrame constructor: CFrame.new(vec3 eye, vec3 lookAt). You would do this before moving the object. Your lookAt would be the Mouse position and your eye would be the objects position.

6 Likes

Do you know how I would make the projectile rotate 180 degrees. It shooting the right direction but the part is backward.

Here a clip:

https://gyazo.com/f63135e2b65d91614a4e45b908ab1d10

Script:

NFX.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0.5,-7) * CFrame.Angles(math.rad(0),math.rad(180),math.rad(0))

NFX.CFrame = CFrame.new(NFX.Position, Mousepos)
1 Like