#Better ways to physically control projectiles?

32 messages · Page 1 of 1 (latest)

stuck cipher
#

Whenever i make a new instance (the projectile) and apply impulse on the instance , it freezes for a split second and then flies forward like its meant to. I want it to not freeze like that. If there is other ways to control projectiles to simulate a bullet or anything like that let me know.

stuck cipher
#
    if requestInfo then
        local projLaser=Instance.new('Part',workspace)
        --projLaser.CanCollide=false projLaser.CanQuery=false
        projLaser.Color=Color3.fromRGB(226, 93, 95)--projLaser.Color=Color3.fromRGB(82, 124, 174)
        projLaser.Material=Enum.Material.Neon 
        projLaser.Size=Vector3.new(0.5,0.5,3)
        projLaser.CFrame=requestInfo[2]
        projLaser.CFrame=CFrame.lookAt(projLaser.Position,requestInfo[1].p)
        
        local upforce = Instance.new("BodyForce")
        upforce.force = Vector3.new(0, projLaser:GetMass() * game.Workspace.Gravity-ToolConfig[8], 0)
        upforce.Parent = projLaser
        
        projLaser:ApplyImpulse(projLaser.CFrame.LookVector*300)
        
    end
stuck cipher
#

@alpine yew I wont be able to respond until 3-4 PM WST

worthy karma
#

Hello there, I noticed that you are using BodyMovers on that projectile, and that makes the projectile run using the roblox physics handler. The Split Second Freeze happens because ROBLOX is auto managing the NetworkOwnership of the projectile

#

If you'd like to fix that, you could use the method SetNetworkOwnership(nil) available on BaseParts

#

Call it on the part as soon as you create it, and hopefully it will fix the delay

#

I don't have the API documentation of SetNetworkOwnership on me right now, but you can find more info about it on the API

worthy karma
#

If SetNetworkOwnership(nil) doesnt work, try using SetNetworkOwnership(Player)

lost notchBOT
#

studio** You are now Level 1! **studio

worthy karma
stuck cipher
#

Ok so i set the Ownership to nil and gave me the same result and when i set the Ownership to Player it, It seems as if :ApplyImpulse() doesnt work

stuck cipher
#

any reasons to why its doing this @worthy karma

worthy karma
#

are you parenting the part to workspace prior to the SetNetworkOwnership call

stuck cipher
#

I wasnt but i figured out why

#

Apparently you need to constantly set it

#

which is what i did and it worked

#

but when the part is out of the clients render, the part freezes

worthy karma
#

well you shouldn't need to call SetNetworkOwnership multiple times

#

this is bad for the networking and for physics emulation ya

stuck cipher
#

yeah

#

how would you go about a physics controlled projectile

worthy karma
#

well personally I'd avoid physics controlled projectiles

#

i'd rather use fastcast and run the projectile with raycasting

#

but since you've asked, the last time I mad a physics-controlled projectile was by 2017, when BodyVelocity wasn't deprecated. I had the same problem as you, and I think I fixed it by using SetNetworkOwnership and pre-generating Parts & BodyMovers when the script was initialized. These 'TemplateParts' and 'TemplateBodyMovers' were then cloned per request afterwards, speeding up the script

stuck cipher
#

hmm

#

Maybe i wont physically control the projectile

#

any guides on the internet that control projectiles without physics and have a smooth trajectory

#

that you know of

worthy karma
worthy karma
#

If you don't want to use FastCast, you can CFrame projectiles on the server using math, and then tell the clients to interpolate the projectile's position according to it's velocity, acceleration and other properties