How do you change a part's bounciness?

I am currently creating a custom character controller without any humanoids. I decided against creating my own version of Humanoid.HipHeight and instead opted to just use the collision. (A.K.A the capsule you see in the GIF). My problem is that when the character falls onto the ground from a height he starts to bounce a little bit until he finally rests on the ground. I don’t want this. I want the character to hit the ground and stay on it.

Thanks in advance!

4 Likes

You will want to change the Elasticity in the CustomPhysicalProperties property in your part. Elasticity determines how “elastic”, or how much kinetic energy/speed is kept during a collision, with 0 being none (no bounce) and 1 being all of it (very bouncy). In this case, since you want your custom character to not bounce, you will want to set it to 0.

13 Likes

A side question. My character slides down slopes, but I don’t want this either. I could set the friction to one but that makes climbing the slopes impossible. Is their another alternative?

2 Likes

It is fairly difficult because you simultaneous want the character to move when wanted and not move when want wanted. You could temporarily increase the friction when no inputs are pressed, but could have unwanted side-effects.

1 Like

Alright, I’ll have to do that without relying on the physics properties. I’ll most likely give a force in the opposite direction if the stepness is less then zero, thanks anyways!

1 Like

Were you ever able to solve the sliding issue? I am currently stuck on that myself.

1 Like

Honestly not sure, I haven’t touched this project in a while. Off the top of my head, there are two solutions I can think of. Either use a HipHeight system so that the collider doesn’t touch the ground, or maybe anchor the collider when it shouldn’t be moving.

1 Like

I tried a hip height system in a previous iteration of my controller. It made slope standing and climbing up steps of a set height very easy, but it also means the controller interacts with the world very differently. The ability to slide up a ramp and carry vertical velocity off of a jump, almost like a car, is very important to me. Idk if it is to you but if you ever come back to this project that might be an issue.

I actually just managed to solve the issue. It needs some polish to make the movement speed feel a bit more consistent while walking on slopes but what I did was I added a force to my character that counteracts the workspace gravity so that I can control gravity on the controller however I like. My character is only affected by gravity while it is in its air move state. This prevents the character from sliding down slopes. Then, in order to prevent the controller from bouncing when moving down slopes, and to lay the groundwork for consistent feeling movement I have made it so when the controller is grounded the desired movement direction is clipped to be parallel to the plane of the slope using this function:

--[[
Clip a vector to be parallel with the normal's plane.
]]--
local function ClipVelocity(vel_in, normal, overbounce)  -- for overbounce I use 1.001
	local backoff;
	local vel_out = ZERO; -- zero vector constant
	
	backoff = vel_in:Dot(normal);
	
	if (backoff < 0) then
		backoff = backoff*overbounce;
	else
		backoff = backoff/overbounce;
	end
	
	local change = normal*backoff
	
	return Vector3.new(vel_in.X - change.X, vel_in.Y - change.Y, vel_in.Z - change.Z)
end

I haven’t done it yet but I should be able to scale the horizontal aspects of the movement speed so that the player doesn’t feel slower on slopes but this should be enough to solve the sliding problem.

1 Like