4581quzwi
(Senior_Builder)
#1
I created a snowball that you can throw and upon impact it it splashes
Unfortunately when I throw the snowball it sometimes explodes mid air!
here are some examples:
Video example
2022-09-19 02-38-32
Video from second perspective
Streamable
This is my the script:
local newclone = toclone:Clone()
newclone.Parent = workspace
newclone.Position = plr.Character.Head.Position + (plr.Character.Head.CFrame.lookVector * 4)
local BF = Instance.new("BodyForce", newclone)
BF.Force = plr.Character.Head.CFrame.lookVector * 150 *dur + Vector3.new(0, 1/dur, 0)
newclone.Name = plr.Name.." Snowball"
newclone.CanCollide = true
newclone.Touched:Connect(function(touch)
if touch.Parent ~= script.Parent.Parent then
print(touch.Name)
newclone.ParticleEmitter:Emit(10)
newclone.Anchored = true
newclone.BodyForce:Destroy()
newclone.Transparency = 1
wait(.7)
newclone:Destroy()
end
end)
Any suggestions or fixes for this problem are appreciated.
Thank you in advance!
Pegagittt
(Pegagit)
#2
local newclone = toclone:Clone()
newclone.Parent = workspace
newclone.Position = plr.Character.Head.Position + (plr.Character.Head.CFrame.lookVector * 4)
local BF = Instance.new("BodyForce", newclone)
BF.Force = plr.Character.Head.CFrame.lookVector * 150 *dur + Vector3.new(0, 1/dur, 0)
newclone.Name = plr.Name.." Snowball"
newclone.CanCollide = true
newclone.Touched:Connect(function(touch)
if touch.Parent ~= script.Parent.Parent then
if touch.Parent:FindFirstChild("HumanoidRootPart") then
print(touch.Name)
newclone.ParticleEmitter:Emit(10)
newclone.Anchored = true
newclone.BodyForce:Destroy()
newclone.Transparency = 1
wait(.7)
newclone:Destroy()
end
end
end)
Try this
If it dont works show me what touch.Name prints
koziahss
(Agent_Invalid)
#3
You should be using fastcast for projectiles. Especially small and fast moving
There are other problems too. So for now I’ll give some pointers:
- Body Movers are deprecated. Use Attachment forces or impulses instead.
- TouchedEvents are inaccurate for small fast moving objects. It’s highly recommend to use raycasts.
- It’s best not to use the second argument for Instance.parent as instances take slightly longer to load into the workspace
- Physics object should ideally be set to the server(for security and consistency between clients)
2 Likes
4581quzwi
(Senior_Builder)
#4
same problem! it prints baseplate
4581quzwi
(Senior_Builder)
#5
Ill try this sounds legit! Could you maybe explain what you mean with 4. Since the force already is server sided
koziahss
(Agent_Invalid)
#6
Okay well it’s be better to read it for yourself as the documentation explains how it works in a much more cornice way than I could ever hope to.
But I will explain later.
BasePart:SetNetworkOwner()
is the method to send a part to server physics.
At the moment we are heading to the funeral ttyl
4581quzwi
(Senior_Builder)
#7
Thank you for your solution!
Thank you for going out of your way to reply to this post!
…
here is a video for anyone interested!
for anyone in the future trying:
I found this tutorial going deep into the “basics” of fastcast
koziahss
(Agent_Invalid)
#8
Would you still like me to briefly explain the other points?