Make projectile shoot direction Character is facing WITH Top Down Camera?

So I have a top down camera and I just want my projectile to shoot in the direction the character is facing. It seems like it is always off by quite a bit, it’s very inaccurate. I am using the LookVector of the HumanoidRootPart to determine where the Character is facing, but the projectile seems to be totally swayed when moving?

Here is a GIF of what I am talking about, I keep the mouse focused on the middle target, which the HRP focuses on the mouse position. But the arrows both shoot off to the side?

https://gyazo.com/9b62581fdfef452c7ef3892c4f75f5d6

Here is the piece of the code that handles the direction. I am using FastCast but I don’t believe that has anything to do with the problem. I am almost positive it has to do with how I am getting the characters direction.

local Origin = Tool.Handle.Position
local Direction = Chr.HumanoidRootPart.CFrame.LookVector

Tool.Handle.Shoot:Play()
Caster:Fire(Origin, Direction, 200, CastBehavior)

Any help is appreciated :slight_smile:

If the character is facing the mouse, and you want to shoot at the mouse, then you could just make the lookvector from tool handle position to the mouse.

local Origin = Tool.Handle.Position
local Direction = (mouse.Hit.Position - Origin).Unit

Tool.Handle.Shoot:Play()
Caster:Fire(Origin, Direction, 200, CastBehavior)
1 Like

so im going to assume you dont want the bullet to shoot up or down so you could use the direction to be:

mouse.Hit.Position but 0 on the Y
example: mousePos = Vector3.new(mouse.Hit.Position.X, 0, mouse.Hit.Position.Z)

then for the direction
direction = (mousePos - Origin).Unit * dist
dist is just a variable usually used for raycasting but since you are using fastcast this will make no difference

1 Like

In your original code you need to multiply the direction by the max distance.

1 Like

This is the solution I was looking for thank you! I was having a brain fart last night and couldn’t piece together simply going along the X and Z axis without adjusting the Y.