How can I make players instantly change direction at high walkspeeds?

I’ve been trying to think of ways to make players turn smoothly at high walkspeeds. Basically sharp changes in direction without them sliding around. I’ve tried using BodyVelocity but the outcome was buggy with only a little improvement.

This fast turns in this game is basically what I’m trying to replicate^

local player = game.Players.LocalPlayer

local function ChangeVelocity()
	if player.Character.Humanoid.MoveDirection == Vector3.new(0,0,0) then
		game["Run Service"].Heartbeat:Wait()
		player.Character.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new()
	else
            -- I previously instanced bodyvelocity here but it was buggy
	end
end

player.Character.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(ChangeVelocity) 

Just to bump, any help or suggestions is appreciated.

How fast is your WalkSpeed?
Can’t you just increase Friction to allow them to turn without sliding?

2 Likes

The game is basically a speed simulator so WalkSpeed is based on their stats. I’ve never messed with friction but i’ll look into it.

I tried to implement the solution from this post but didn’t notice a change. Here is the updated code

local player = game.Players.LocalPlayer

local function changeFriction(part, friction, frictionWeight)
	if not part.CustomPhysicalProperties then
		part.CustomPhysicalProperties = PhysicalProperties.new(part.Material)
	end
	local orig = part.CustomPhysicalProperties
	friction = friction or orig.Friction
	frictionWeight = frictionWeight or orig.FrictionWeight
	print(friction)
	part.CustomPhysicalProperties = PhysicalProperties.new(orig.Density, friction, orig.Elasticity, frictionWeight, orig.ElasticityWeight)
end

local function ChangeVelocity()
	if player.Character.Humanoid.MoveDirection == Vector3.new(0,0,0) then
		game["Run Service"].Heartbeat:Wait()
		player.Character.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new()
	else
		changeFriction(player.Character.HumanoidRootPart, 20, 20)
	end
end


player.Character.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(ChangeVelocity) 

id just use a linearvelocity on the plane type, changing the x-y values based on player input. and disable it when a player is in the freefalling state, or anytime you can detect they aren’t touching the ground. i dont think the flash game uses walkspeed because when you jump you aren’t launched in the same way as if you had incredibly high walkspeed.

You could set the humanoid root part velocity to Vector.zero when a player changes the direction (MoveDirection changed).

This will cause the player to constantly stop since it fires every time the player chances direction.

Why not just manually increase the Friction of all the ground Parts?
I don’t think it’ll affect other aspects too much unless you have other physical objects interacting with the ground.

2 Likes

I was up late last night and just realized I was changing the friction of the HumanoidRootPart which of course wouldn’t change anything. I should have been changing the friction of the player’s feet when their character is added.

local player = game.Players.LocalPlayer

local function changeFriction(part, friction, frictionWeight)
	if not part.CustomPhysicalProperties then
		part.CustomPhysicalProperties = PhysicalProperties.new(part.Material)
	end
	local orig = part.CustomPhysicalProperties
	friction = friction or orig.Friction
	frictionWeight = frictionWeight or orig.FrictionWeight
	part.CustomPhysicalProperties = PhysicalProperties.new(orig.Density, friction, orig.Elasticity, frictionWeight, orig.ElasticityWeight)
end

changeFriction(player.Character.LeftFoot, 2, 100)
changeFriction(player.Character.RightFoot, 2, 100)

This works much better than my original script so i’ll mark your reply as the solution. Thanks for the replies and help.

If I recall correctly the Friction of the legs wouldn’t help since they are CanCollide off so the player doesn’t get tripped or hung up on things like stairs. HipHeight sets how high a player is above the ground so CanCollide off legs isn’t a problem.