Make a part get flinged to camera direction using bodyforces

  1. What do you want to achieve? Keep it simple and clear!

Hey! I was wondering how could I get to make a sort of flinging when dropping part system, what I want to achieve is getting the part to fling to the camera’s current direction / lookvector (I think) whenever you trigger the dropping part thing (I have already done that)

  1. What is the issue? Include screenshots / videos if possible!

The bodyforces dont work at all, maybe it’s because the lookvectors keep being output negatively (I tried reversing them) but I am clueless on how to fix it.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

					local Debris = game:GetService("Debris")
					local bodyforce = Instance.new("BodyForce")
					bodyforce.Force = Vector3.new(((math.abs(currentcamera.LookVector.X)*-1)*100), 0, ((math.abs(currentcamera.LookVector.Z)*-1)*100))
					print(GrabObject)
					bodyforce.Parent = GrabObject
					GrabObject = nil
					Debris:AddItem(bodyforce, 0.5)

Thank you so much for helping!

What is currentcamera? If it’s workspace.CurrentCamera.CFrame, are you updating it every time?

Ignoring that potential issue, you don’t want to take the abs of the lookvector, that will make everything go in the +X, +Z directions (or flipped since you negate it).

They should be doing something, but they might just not be strong enough. You could try to multiply the mass of the object to scale it, but also increase your multiplier:

local Debris = game:GetService("Debris")

local FORCE_MULT = 1000 -- modify this

local bodyforce = Instance.new("BodyForce")
bodyforce.Force = FORCE_MULT
	* (workspace.CurrentCamera.CFrame.LookVector * Vector3.new(1, 0, 1)).Unit
	* GrabObject.Mass
bodyforce.Parent = GrabObject
GrabObject = nil
Debris:AddItem(bodyforce, 0.5)

Edit: Added .Unit so that the up/down angle doesn’t affect the force magnitude.

1 Like