Is there anyway to distinguish mouse wheel movements up from down while using ContextActionService, for example:
game:GetService(“ContextActionService”):BindAction(“MouseWheel”,function(name,state,input)
end,false,Enum.UserInputType.MouseWheel)
Using this, I haven’t been able to find a way to distinguish between mouse wheel movements up and down, so currently I am using Mouse.WheelForward and Mouse.WheelBackward
2 Likes
This information can be pretty hard to find if you don’t know where to look.
Looking at the wiki page for BindAction, it seems like the third argument that is passed to the handler function is an InputObject. InputObjects have a Position property, which is a Vector3 value. When an InputObject “belongs to” a mouse wheel event, the Z component of InputObject.Position is either -1 or 1, depending on which direction the mouse wheel was scrolled. 1 is forward, -1 is backward.
local ActionS = game:GetService("ContextActionService")
function handler( name, state, input )
if input.Position.Z == 1 then
print("Mouse wheel scrolled forward")
else
--can't be 0 since it's a mouse wheel event (right?)
print("Mouse wheel scrolled backward")
end
end
ActionS:BindAction("MouseWheel", handler, false, Enum.UserInputType.MouseWheel)
21 Likes