Third Person Projectile Help

In my game, the players camera center is used to determine where bullets should go. This is fine from a gameplay standpoint and works well. However, visually, it looks like this.

https://i.gyazo.com/b10600959ce12945fbedae9817ee23f6.gif

What I want is to change the projectile starting point (on the client, purely visual) so it can come out of a hand or a weapon or wherever I need it to come out. However when I change the origin, the visuals don’t match up with what’s actually happening.

https://i.gyazo.com/24dc369e9ab6e5b68670ccc3ea891014.gif

I am horrible at math and having a hard time trying to figure out how to make up for the difference visually while maintaining clarity.

Here is the code on the Client that is firing the projectile.

local currentCamera = workspace.CurrentCamera
local VIEWPORT_SIZE = currentCamera.ViewportSize -- current size of the screen -- if you're raycasting multiple times, this will have to be redefined!
local maxDistance = weaponAttributes["Max_Distance"]
local myParams = RaycastParams.new()
myParams.FilterType = Enum.RaycastFilterType.Exclude
myParams.FilterDescendantsInstances = {myCharacter}
local unitRay = currentCamera:ViewportPointToRay(VIEWPORT_SIZE.X / 2, VIEWPORT_SIZE.Y / 2)-- + game:GetService("GuiService"):GetGuiInset().Y) -- account for the 36px TopBar inset
module.abilityEvent:FireServer("PrimaryFire", {unitRay.Direction, unitRay.Origin})

And then the Server sends out an event with the important things so the clients can fire their own bullet. Currently it’s the same as the server where it just fires a FastCast cast with all the same attributes.

local simBullet = myCaster:Fire(origin, direction, weaponAttributes["Bullet_Speed"], CastBehavior)

Here’s a better example of the issue I’m having! When I’m doing it from the center of the screen, you can see that it follows the crosshair exactly and goes over.
https://i.gyazo.com/a1557f975a0c991752f0d0e335cacda6.gif

However, when tweaking the code to use an origin point that isn’t the center of the screen it no longer looks proper visually as it hits the wall.
https://i.gyazo.com/148a15d8f957c237eb223914ba92699e.gif

I’ve tried using code from my previous post about this but it doesn’t change the issue at hand.

2 Likes