I know that mobile and touch devices have certain extra functions and am wondering if there are any PC equivalents or atleast some ways to go about scripting something of the sort.
What specifically are you trying to achieve may I ask? To go along with Swipe but for PC (Depending what you are wanting) I would use MouseWheel, or some sort of Click and Drag Function.
Do you mean like TouchLongPress
for example?
You could try utilising Mouse.Button1Down
and Mouse.Button1Up
, detecting a change in position (using UserInputService:GetMouseLocation()
) if you need.
The closest thing i can think of is that slap mechanic in talking ben when you swipe left/right on the head and they move accordingly.
That’s interesting. Almost like using Gyroscope but for PC. However the solution for Gyro and Swipe is Mouse Movement.
I’ve made an Example to help you build upon.
All this is doing is Detecting how fast the Player’s Mouse is moving while MB1 is held Down.
We use code from this Post to Check the Speed of the Mouse, and this Post to check for the Direction of the Mouse.
Click for - Simple Mouse Swipe Code
local mouseMover -- Holds Function (so we can Disable Whenever)
local function startMouseMove()
local mouse = game.Players.LocalPlayer:GetMouse()
local LastPosition = Vector2.new(0,0)
mouseMover = mouse.Move:Connect(function() -- Fires Everytime Mouse Moves
if uis:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then -- Checks if MB1 is Pressed
local dis = math.floor((Vector2.new(mouse.X, mouse.Y) - LastPosition).Magnitude + 0.5) -- (⓿_⓿)
if dis > 70 then -- How Fast Mouse needs to Move
print("hit!")
if math.abs(mouse.X - LastPosition.X) > math.abs(mouse.Y - LastPosition.Y) then
if mouse.X - LastPosition.X > 0 then
print("right!")
else
print("left!")
end
else
if mouse.Y - LastPosition.Y > 0 then
print("down!")
else
print("up!")
end
end
end
LastPosition = Vector2.new(mouse.X, mouse.Y) -- has to be after Direction Check
end
end)
end
local function endMouseMove()
if mouseMover then -- make sure it's active
mouseMover:Disconnect()
end
end
task.wait(2)
startMouseMove() -- start
task.wait(20)
endMouseMove() -- end
I think also in the #resources, someone posted a mouse movement swing for a sword… might have been a social media drocsiD post, but I tested it out and it was pretty cool swinging a sword with your mouse.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.