Fastcast projectile lagging behind while moving

so yeah the title explains it. how do i fix this

update code:

local bulletLength = bullet.Size.Z / 2
local pos = origin + direction
bullet.CFrame = CFrame.new(pos, pos + direction) * CFrame.new(0, 0, -(length - bulletLength))

this is client sided

local bulletLength = bullet.Size.Z / 2
local pos = origin + direction
local bulletCFrame = CFrame.new(pos, pos + direction) * CFrame.new(0, 0, -(length - bulletLength))
bullet.CFrame = bulletCFrame

By calculating the CFrame once and storing it in a variable, you can avoid the performance hit of recalculating it every frame.

Try calculating the CFrame once and then store it in a variable, it might help but I dont really know

what?
this code works completely fine when not moving

im trying to get the projectile to stay in line with the fire origin while moving
as seen in the video its falling behind

But you can’t because you are moving so when you shoot theres a little start since the part you put the ball spawn so thats why, I think theres not really a way to fix it.

i seen this done in other games that use fastcast
i know there is a way to modify the cast updated callback function to position the bullet correctly
thats what im looking for

If I’m not wrong, can’t you adjust the bullet velocity as well in fast cast?

Yeah but I think he wants it like firing on the start (it is but its slow so thats why it goes kinda back) so yeah, as Ant said, maybe adjust the bulle velocity make the fire better? IDK, just play w the settings.

i tried changing the velocity based on the linear velocity of the player
it doesnt work

i have tried everything. nothing works. only way to do it is position it through cframe

Just an idea, but maybe instead of setting the start position as the cannon, you set it as the cannon + the ship velocity, that way when the cannon ball fires it should be taking into account when the ship is moving.

The update code shouldn’t need to be changed, just the original position when you first shoot

it worked but looks more like a temporary solution so if anybody has anything better tell me

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.