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?
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)
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)
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
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.