I have a problem where the bullet (projectile) gets offsetted when it’s moving fast enough:
This is a video of the behavior:
This is how the projectile is structured:
Any potential fixes? And yes this is being replicated on the client.
I have a problem where the bullet (projectile) gets offsetted when it’s moving fast enough:
This is a video of the behavior:
This is how the projectile is structured:
Any potential fixes? And yes this is being replicated on the client.
Bump \\\\\\\\\\\\\\\\
How are you setting the initial CFrame of the projectile? You said it’s replicated to the client, does that mean the client creates and handles the projectile?
Seems to me that the reason it’s happening is because instantiating a new part is slow, compared to calculating some vectors. So whilest the projectile is spawning, it’s already traveling a few frames. You could fix it by readying a projectile beforehand, and just setting it to be invisible
Could be a typo of yours but, what do you mean by “readying”?
local TargetPosition = targetInfo[1]
local TargetHit = targetInfo[2]
local Distance = (origin.Position - TargetPosition).Magnitude
local Direction = (TargetPosition - origin.Position).Unit
local Speed = (1 / projectileOptions.Speed) * Distance
local newProjectile = ProjectileTemplate:Clone()
newProjectile.Position = origin.Position
newProjectile.Parent = DebrisFolder
TweenService:Create(newProjectile, TweenInfo.new(Speed, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Position = TargetPosition}):Play()
Creating a projectile beforehand. So you’d create the bullet, make it invisible, and then when the player fires it just uses the created bullet.
A better way would be to just cache some projectiles, and then any gun can just ask for projectiles and reuse them.
Could give an example code if possible?
Nvm I fixed it I guess, just had to add a task.wait(.1)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.