What ways to remove velocity from a character

I am having an issue in my game where characters falling from a great height, will hit the Terrain, and go through it. Some characters in my game are scaled down.
So, I was thinking of adding a .Touched event to the HRP, and if the Terrain is touched, and the characters Y velocity has been in the negative for over 1 second, then I will stop the characters falling, and make sure they are placed above the Terrain at their current X,Z coordinates.

However, even when I anchor them, or cframe them, the velocity remains.
So, what are the best and most effective ways to stop the velocity of the parts in a character model.?

Thanks.

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Why not just have a minimum Height a player’s character HRP can be at, and whever a player’s character HRP position changes you check if its below that height and if it is respawn them onto the map.

Thats more avoiding the issue rather than solving it, but I do appreciate the input.
However, knowing how to effectively stop velocity will not only help me in other areas but might help someone else.

For insance, when I had a pet that followed the player (flying), if the player was too far away, the pet would ‘spawn’ (cframe) to the player, but the velocity of the pet would make it shoot past the player after spawn. So even in that case knowing how to stop the velocity would help.

This should work

local function removeVelocity(character)
	local vectorZero = Vector3.new(0, 0, 0)
	character.PrimaryPart.Velocity = vectorZero
	character.PrimaryPart.RotVelocity = vectorZero
end
3 Likes

I will try this later when I am home

you could use Vector3.zero instead of creating your own

2 Likes

Wow had no idea these existed. I always made my own too.

Properties

Vector3 Vector3.zero
A Vector3 with a magnitude of zero.

This API member is a constant , and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

  1. print(Vector3.zero) → 0, 0, 0

Vector3 Vector3.one
A Vector3 with a value of 1 on every axis.

This API member is a constant , and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

  1. print(Vector3.one) → 1, 1, 1

Vector3 Vector3.xAxis
A Vector3 with a value of 1 on the X axis.

This API member is a constant , and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

  1. print(Vector3.xAxis) → 1, 0, 0

Vector3 Vector3.yAxis
A Vector3 with a value of 1 on the Y axis.

This API member is a constant , and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

  1. print(Vector3.yAxis) → 0, 1, 0

Vector3 Vector3.zAxis
A Vector3 with a value of 1 on the Z axis.

This API member is a constant , and must be accessed through the Vector3 global as opposed to an individual Vector3 object.

  1. print(Vector3.zAxis) → 0, 0, 1
2 Likes

Yep, really neet set of functions.

cough screams with deprecated intently

local zeroVelocity = Vector3.new(0,0,0)

local function removeVelocity(character)
    local primaryPart = character.PrimaryPart
    primaryPart.AssemblyLinearVelocity = zeroVelocity
    primaryPart.AssemblyAngularVelocity = zeroVelocity 
end
2 Likes

Erm? “screams with deprecated intently” what?

.Velocity and .RotVelocity have been deprecated (replaced) by .AssemblyLinearVelocity and .AssemblyAngularVelocity.

See the note at the top of these articles:
BasePart.Velocity (roblox.com)
BasePart.RotVelocity (roblox.com)

3 Likes

i always do Vector3.new() but your suggestion might be faster to type (lol i just realised you bumped it, is bumping a thread forgivable if you give advice like how you did?)

1 Like

No Idea, I may have committed a crime.

2 Likes

And of all my threads, I have created, this was one, where the solutions given just didn’t seem to work for me, and so I moved on to other things, yet it always bothered me that I couldn’t get velocity of a part to stop, and THIS is the one that gets bumped, and so I keep getting notifications for all these replies. XD So, please lets just let it die.

1 Like