What do you want to achieve? Keep it simple and clear!
I’m using FastCast for projectiles in my custom gun system.
I want the bullets to go accurately towards the mouse when aiming upwards in third person; instead they are going under and to the left/right of the crosshair.
In the second half of the video I demonstrated with the FastCast Example Gun to compare how the bullets go towards the mouse accurately. I find this strange as I used the exact same calculations as the example gun to get the firing direction.
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I searched for DevForum topics with keywords relating to my issue but found nothing. I used Ctrl+F to search in the FastCast thread for similar issues, but no result.
-- Calculation to get firing direction
local direction = (mousedirection - FirePoint.Attachment.WorldPosition).Unit
local directionalCF = CFrame.new(Vector3.new(), direction)
local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)), 0, 0)).LookVector
local modifiedBulletSpeed = (direction * BulletSpeed)
caster:Fire(firepoint.Attachment.WorldPosition, direction, modifiedBulletSpeed, raycastbehavior)
-- FastCast example gun's calculation is exactly the same so I don't know why it is functioning differently
The bullets are “going” to where your mouse is hitting for facing, but because the barrel of your gun is lower, it will look like your bullets are actually lower than your mouse is, you can verify this by testing your bullet velocity direction by making your firepoint from you camera.
I’ve also used FastCast to make my own weapon system, many games use 2 instances for bullets where one is created on the client only (for visuals only) to make it look likes it is being fired out the gun, and another on the server that only others players can see but is invisible to you the player that fired it, making the client not see two bullet instances whilst still looking correct visually.
This video does shown the correct thing happening that you want to achieve but it is very hard to notice any displacement due to being fired from the gun firepoint locally (it may be hard to see the little red pellets)
There’s definitely something wrong with your direction vector.
I don’t think you need to do this. You can directly use mousedirection as the direction vector. There’s no need to get the displacement between that and the gun muzzle; that might end up making it worse.
Here’s a rough visualization of what could be happening:
The thing is the example gun uses the exact same code as mine, but it doesn’t have this problem. Maybe it’s because my gun is further from the body?
I think your diagram is correct in visualizing the issue. I will experiment with the code and move the position of the gun to see if it behaves differently.
you can verify this by testing your bullet velocity direction by making your firepoint from you camera.
Yes, I noticed the bullets are accurate when I shoot from first person. I’m just confused why the example gun doesn’t have the issue in third person, but I realize it’s maybe a difference in the size/distance of the gun from my character.
many games use 2 instances for bullets where one is created on the client only (for visuals only) to make it look likes it is being fired out the gun, and another on the server that only others players can see but is invisible to you the player that fired it, making the client not see two bullet instances whilst still looking correct visually
for anyone in the future reading this: in my own personal usage the cause of this is the “Acceleration” castBehavior, if you set the Acceleration castBehavior at the start to be affected by gravity it causes the projectile to immediately start falling down causing it to look like its going below the mouse.
if you want to avoid this do a slight delay then use the :SetAcceleration() method on the ActiveCast that you get from the fired caster so that bullet shoots straight at first then after the delay time starts becoming effected by gravity