How would I make this?

Y’know in battleground games when you get hit and knocked upwards, and then when you fall onto the ground there is a sound effect and/or a crack decal and/or a rock effect and/or debris etc? Or when you get knocked back into a wall and the same effects are on the wall? How can I know when they have landed or hit into the wall and what position on the floor or wall they hit?


Have you tried using raycasting?
Multiply the raycast by * 3 instead of *1000 like people normally do for a building system so with the *3 it will only go 3 studs so u will know when the play is on the wall

1 Like

But what direction would I fire the raycast in?

1 Like

the opposite way of the Knockback I would say

store the previous position in a variable and to get the current position do local direction = (currentPosition - previousPosition).Unit to get the direction the player is moving in, then add that to the raycast with a distance of like 3 or something small because you want the effect to enable once they actually hit the ground.

Then to get the ground orientation for the crack effect, you have to use the raycast normal. local groundCrackCFrame = CFrame.lookAt(raycastResult.Position, raycastResult.Position + raycastResult.Normal)

Ohh sorry not opposite of the Knockback the same direction of it

But the direction wont stay the same because I delete the velocity after 0.1 seconds and then the players speed in the air decreases

1 Like

You want when the player is thrown, lets say into a wall and they hit the wall, there will be a crack on the wall. Or if the player is thrown into the air and hits the ground the crack will be on the ground correct?

None of that matters if you just cache the previous position and compare it to the new position like I wrote above in a loop until the raycast hits something or times out

Both, yes [charlimit] [char limit]

1 Like

How would I save the previous position?

1 Like

Some basic pseudocode to get you started. Commented some parts but if there’s something you don’t understand lmk

	local raycastParams = ...
	local previousPosition = character.PrimaryPart.Position
	local currentPosition = character.PrimaryPart.Position
	local raycastDistance = 3
	local direction
	local connection = nil

	connection = RunService.Heartbeat:Connect(function()
		currentPosition = character.PrimaryPart.Position
		direction = (currentPosition - previousPosition).Unit --direction here

		if currentPosition ~= previousPosition then
			--raycast towards the direction the player is being thrown in
			local raycastResult : RaycastResult? = workspace:Raycast(character.PrimaryPart.Position, direction * raycastDistance, raycastParams)
			if raycastResult then
				--create a new part and set its cframe
				local crackPart ="Part")
				crackPart.CFrame = CFrame.lookAt(raycastResult.Position, raycastResult.Position + raycastResult.Normal)
				crackPart.Parent = workspace

				--disconnect the connection
				connection = nil

		--set the new position here
		previousPosition = currentPosition