Having trouble replicating a special movement system

I’m trying to replicate a movement system from a unity game into my game. This is how its meant to work. The player controls a humanoid mech outfitted with special thrusters.

The player can walk around normally with WASD.
However, when the player holds down space, the thrusters activate.

When the player is using these thrusters without WASD down the mech will fly upwards.
When the player is trying to use WASD with the thrusters then they will orient in that direction and push the player in that direction. As displayed in this video snippet.

Right now what I’ve tried is using a LinearVelocity Constraint on the Line setting and it would basically orient the attachment in a certain direction when space is held down. The main problem is friction of the player and the ground and using MaxVelocity = inf. really isn’t ideal and I just don’t get how to circumvent that. On top of that I don’t get how to compound movement keys where W and A/S are held down so the player can move in a diagonal direction.

Clearly this isn’t working so if anyone can help me out It’d really help.

UIS.InputBegan:Connect(function(i,gp)
	--if gp then return end
	if not gp and i.KeyCode == Enum.KeyCode.Space then
		spaceDown = true
	end

	if i.KeyCode == Enum.KeyCode.W then
		currentMoveVector = "Forward"
		Angle = OriginalAngle + Vector3.new(0,0,90)
		print(Angle)
		checkMove()
	end
	if (i.KeyCode == Enum.KeyCode.W and UIS:IsKeyDown(Enum.KeyCode.D)) or (i.KeyCode == Enum.KeyCode.D and UIS:IsKeyDown(Enum.KeyCode.W)) then
		currentMoveVector = "FrontRight"
		Angle = OriginalAngle + Vector3.new(-90,0,90)
		checkMove()
	end
	if (i.KeyCode == Enum.KeyCode.W and UIS:IsKeyDown(Enum.KeyCode.A)) or (i.KeyCode == Enum.KeyCode.A and UIS:IsKeyDown(Enum.KeyCode.W)) then
		currentMoveVector = "FrontLeft"
		Angle = OriginalAngle + Vector3.new(90,0,90)
		checkMove()
	end

	if i.KeyCode == Enum.KeyCode.D then
		currentMoveVector = "Right"
		Angle = OriginalAngle + Vector3.new(-90,0,0)
		checkMove()
	end
	if i.KeyCode == Enum.KeyCode.A then
		currentMoveVector = "Left"
		Angle = OriginalAngle + Vector3.new(90,0,0)
		checkMove()
	end
	if (i.KeyCode == Enum.KeyCode.S and UIS:IsKeyDown(Enum.KeyCode.D)) or (i.KeyCode == Enum.KeyCode.D and UIS:IsKeyDown(Enum.KeyCode.S)) then
		currentMoveVector = "BackRight"
		Angle = OriginalAngle + Vector3.new(-90,0,-90)
		checkMove()
	end
	if (i.KeyCode == Enum.KeyCode.S and UIS:IsKeyDown(Enum.KeyCode.A)) or (i.KeyCode == Enum.KeyCode.A and UIS:IsKeyDown(Enum.KeyCode.S)) then
		currentMoveVector = "BackLeft"
		Angle = OriginalAngle + Vector3.new(90,0,-90)
		checkMove()
	end
	if i.KeyCode == Enum.KeyCode.S then
		currentMoveVector = "Back"
		Angle = OriginalAngle + Vector3.new(0,0,-90)
		checkMove()
	end
	local TweenVelOri = Tween:Create(LV.Parent,TweenInfo.new(.5),{Orientation = Angle})
	TweenVelOri:Play()


end)

UIS.InputEnded:Connect(function(i,gp)
	if not gp and i.KeyCode == Enum.KeyCode.Space then
		spaceDown = false
	end
end)

local TweenVel = Tween:Create(LV,TweenInfo.new(1),{MaxForce = 50000})
RunService.Heartbeat:Connect(function()
	
	if spaceDown then
		LV.VectorVelocity = Vector3.new(0,60,0)
		LV.LineVelocity = 100
		if TweenVel.PlaybackState ~= Enum.PlaybackState.Playing then
			TweenVel:Play()
		end
		--[[if workspace:FindFirstChild("Slip") then
			
		end
		local part = Instance.new("Part")
		if humanoid.FloorMaterial ~= Enum.Material.Air then
			part.Name = "Slip"
			part.Anchored = true
			part.Parent = workspace
			part.CFrame = Player.Character.PrimaryPart.CFrame - Vector3.new(0,-30,0)
		else
			part:Destroy()
		end]]
		
		--print(TweenVel.PlaybackState)
		
	else
		LV.VectorVelocity = Vector3.new(0,0,0)
		LV.LineVelocity = 0
		if TweenVel.PlaybackState == Enum.PlaybackState.Playing then
			TweenVel:Cancel()
			--print("Cancelled")
		end
		LV.MaxForce = 0
	end
end)
1 Like

Give the player network ownership will that help?

this has to be done from the servers side.