C4 Physics Assistance

Hello!

What I would like to achieve:
When the C4 touches a part it orients itself to that part and attaches to the wall.
Example:

What the C4 currently does:
image

I have tried checking when the C4 is touched and then rotating it to the part but this has had no luck in looking like I want it. Any ideas?

It would help if you shared the code in its current state!

2 Likes

Without code I can’t be sure, but if you’re raycasting the C4 to the wall you can get the Normal of the raycast to rotate the C4.

Here’s a post that explains what normals are, but basically its a Vector3 that is pointing away from the wall.
https://devforum.roblox.com/t/surface-normal-why-vector3/12654/5

1 Like

The C4 does get raycasted by the client and uses a remote that will be connected with the server. The parameters for the remote include the raycast the client did.

This is part of the server:

    local BV = Instance.new("BodyVelocity",C4)
	BV.MaxForce = Vector3.new(100000000,100000000,100000000)
	BV.Velocity = (Hit - C4.Position).Unit*100
	game:GetService("Debris"):AddItem(BV,.2)
	Trail.Enabled = true
	C4.CanCollide = true
	Conn = C4.Touched:Connect(function(x)
		if CantDetect then return end
		if x:IsDescendantOf(LP.Character) or x.Parent == LP.Character or x:IsDescendantOf(game.Workspace.Players) then return end
		C4.Plant:Play()
        C4.Rotation = x.Rotation
        C4.Anchored = true
        Conn:Disconnect()
end)

This is the client:

local RequestedLocation = CurrentCamera:ScreenPointToRay(Mouse.X, Mouse.Y)

Remote:FireServer("Throw",workspace:FindPartOnRayWithWhitelist(Ray.new(RequestedLocation.Origin, RequestedLocation.Direction * 1000), {}, true))

Solution found!
Using :toworldspace() has achieved the goal I needed. Thank you to all who replied.

1 Like