The title may be a little confusing, but recently I have been trying to configure mobile compatibility with all my gears/tools in my game and I’ve come across some issues with the skills.
Currently, the script works off of an InputBegan and InputEnded method for PC users.
though I just recently added this for mobile -
IceButton.Button.TouchTap:Connect(function(TouchPositions, TouchState)
if Holding.Value == "R" then
isHolding = false
SkillsHandler:FireServer("R", Mouse:GetHit().Position)
Animations.R:AdjustSpeed(1)
else
SkillsHandler:FireServer("Hold", "R")
end
end)
That basically makes the HumanoidRootPart adjust its CFrame towards the look of the mouse. Of course, for mobile, it’s just whatever they tap on the screen.
My issue is that, when the user tries to shoot that direction and press the button at the same time, it directs the humanoidrootpart instantly toward that Image button.
I’ve tried TouchLongPress but I still can’t solve this issue with that. Any idea what I could possibly do? Maybe rework the code or methods I am using?
Little confused with Vector2 though, because I want to make the humanoid root-part look directly at the CFrame of the center in the case you’re telling me.
repeat
local unitRay = currentCamera:ScreenPointToRay(Viewport_Size.X / 2, Viewport_Size.Y / 2 + game:GetService("GuiService"):GetGuiInset().Y)
local raycastResult = workspace:Raycast(unitRay.Origin, unitRay.Direction * CAST_LENGTH, raycastParams)
if raycastResult and raycastResult.Position then
HumRP.CFrame = CFrame.lookAt(HumRP.Position, raycastResult.Position)
end
task.wait()
until Holding.Value ~= "R"
This seems to be facing the character towards the center of the screen, but the opposite way. It’s still shooting towards the ground as well.