Open doonv opened 2 years ago
@Dan-Gamin Please upload a minimal reproduction project to make this easier to troubleshoot.
Also, make sure Emulate Mouse From Touch is enabled in the project settings. See https://github.com/godotengine/godot/issues/24589.
Also, make sure Emulate Mouse From Touch is enabled in the project settings. See #24589.
@Calinou It is enabled. It works on PC. it doesnt work on mobile. I will add a minimal reproduction project soon.
@Calinou Well here the reproduction project. TouchScreen.zip
But it works. But in my game. it doesnt.
Tested on iOS using alpha-3
.
After touching white rectangle just pressed
count increases and log displays InputEventAction: action="test_action", pressed=true
.
Index is increasing the same way it does on M1 Mac. The only issue might be that for sore reason it is increased by 3 (on both macOS and iOS) due to the condition is_action_just_pressed
triggering for InputEventAction
, InputEventMouseButton
and InputEventScreenTouch
.
This is the scene tree of my mobile controls The DashButton has a script because its a temporary solution to this problem. The MobileControls node mainly controls the joystick. Heres that MobileControls script:
extends CanvasLayer
@onready var _jinner: Sprite2D = $JoyStickAnchor/JoyStick/Inner
@onready var _jbutton: TouchScreenButton = $JoyStickAnchor/JoyStick
@onready var _jbutton_tex: Texture2D = _jbutton.texture_normal
@onready var _jbutton_center: Vector2 = _jbutton.position + (_jbutton_tex.get_size() / 2)
@onready var jmax_length: float = _jbutton_tex.get_width() / 2.0
var move_vector: Vector2 = Vector2.ZERO
var _jindex: int = -1
func _ready() -> void:
visible = OS.has_feature("mobile")
func _input(event: InputEvent) -> void:
if ((event is InputEventScreenTouch or
event is InputEventScreenDrag)
and _jbutton.is_pressed() and
(_jindex < 0 or event.index == _jindex)):
_jindex = event.index
move_vector = point_to_move_vector(event.position)
_jinner.position = (move_vector * jmax_length).limit_length(jmax_length - 10)
elif event is InputEventScreenTouch and not event.pressed and (_jindex < 0 or event.index == _jindex):
_jinner.position = Vector2.ZERO
_jindex = -1
move_vector = Vector2.ZERO
# Calculates the joystick move vector from a point
func point_to_move_vector(point: Vector2) -> Vector2:
return ((point - _jbutton_center) / jmax_length).limit_length(1)
You should specify which mobile devices you've experienced this issue on. As I mentioned iOS devices do not reproduce this issue with your current MRP. You should probably also check other project settings or UI settings which could cause an issue to appear.
You should specify which mobile devices you've experienced this issue on. As I mentioned iOS devices do not reproduce this issue with your current MRP. You should probably also check other project settings or UI settings which could cause an issue to appear.
I am using Android.
@Calinou Well here the reproduction project. TouchScreen.zip
But it works. But in my game. it doesnt.
You should also update MRP so that it actually reproduces your issue if it doesn't. Because right now it's not doing it, at least on iOS and from what I understand you also can't reproduce an issue with this MRP.
I have minimized my game to only include the bug. It is reproduceable (at least for me on android). Download the project here.
Edit: I forgot to explain how to reproduce the bug: Basically, you have a little floating player which can move with the joystick. He can also dash. But he can't because the button is broken. Why doesn't he dash?
This is probably related to the https://github.com/godotengine/godot/issues/58550 and should be fixed by now. Please try using new Godot alpha 4 build.
This is probably related to the #58550 and should be fixed by now. Please try using new Godot alpha 4 build.
@Dan-Gamin seems to have this issue on Android so I guess the iOS specific regression fix might not solve it?
This is probably related to the #58550 and should be fixed by now. Please try using new Godot alpha 4 build.
Okay... I will test it out soon.
This is probably related to the #58550 and should be fixed by now. Please try using new Godot alpha 4 build.
Okay... I will test it out soon.
It didn't fix it... I don't think this is related to multitouch since my dash should work without using the joystick (It remembers the last joystick vector).
Also, can anyone else reproduce this issue?
This is probably related to the #58550 and should be fixed by now. Please try using new Godot alpha 4 build.
@Dan-Gamin seems to have this issue on Android so I guess the iOS specific regression fix might not solve it?
My bad. Seems like I've forgotten about it. 🤔
But I wasn't able to reproduce it in alpha-4. At least with the current project. I've had to modify it so it would actually run on new alpha release, I might have done something wrong though.
This is probably related to the #58550 and should be fixed by now. Please try using new Godot alpha 4 build.
@Dan-Gamin seems to have this issue on Android so I guess the iOS specific regression fix might not solve it?
My bad. Seems like I've forgotten about it. 🤔
But I wasn't able to reproduce it in alpha-4. At least with the current project. I've had to modify it so it would actually run on new alpha release, I might have done something wrong though.
@naithar This one.zip should actually reproduce the issue (even on 4.0.alpha4.offical
). By pressing the virtual button on the right while moving. The player dashes, here is how that looks like (exaggerated on the given build for so you can see it better):
Right now I'm getting. And Spirit
is not moving at all.
022-03-10 15:49:55.718494+0300 TouchScreenButton[1451:284049] USER WARNING: Cursor shape not supported by this display server.
2022-03-10 15:49:55.718558+0300 TouchScreenButton[1451:284049] at: cursor_set_shape (servers/display_server.cpp:249) - Cursor shape not supported by this display server.
Right now I'm getting. And
Spirit
is not moving at all.022-03-10 15:49:55.718494+0300 TouchScreenButton[1451:284049] USER WARNING: Cursor shape not supported by this display server. 2022-03-10 15:49:55.718558+0300 TouchScreenButton[1451:284049] at: cursor_set_shape (servers/display_server.cpp:249) - Cursor shape not supported by this display server.
I have never seen that before... On which platform is this on?
iOS, that's the only mobile platform I can test
iOS, that's the only mobile platform I can test
Huh... On Android at least the Spirit
moves. The Cursor shape not supported by this display server.
warning is weird. It seems like its related to custom cursors but I haven't done that, nor is it possible for custom cursors on mobile. Is this maybe a separate issue?
After commenting out all cursor_set_shape
usages, there is no problem on iOS:
https://user-images.githubusercontent.com/3750083/157667568-d50bf819-94e1-4b36-a0c8-7560375225c1.MP4
Edit:
Overriding cursor_set_shape
method with empty method also helps for iOS.
After commenting out all
cursor_set_shape
usages, there is no problem on iOS:IMG_7415.MP4 Edit: Overriding
cursor_set_shape
method with empty method also helps for iOS.
Where? They are no cursor_set_shape
usages in my code.
After commenting out all
cursor_set_shape
usages, there is no problem on iOS: IMG_7415.MP4 Edit: Overridingcursor_set_shape
method with empty method also helps for iOS.Where? They are no
cursor_set_shape
usages in my code.
In engine code.
In engine code.
Interesting... Maybe that fixed the problem? When I run my game on android, I get this warning:
W 0:00:02:0196 set_icon: Icon not supported by this display server.
<C++ Source> servers/display_server.cpp:320 @ set_icon()
Maybe this is the cause since it comes from the same source script that caused your issue?
In engine code.
Interesting... Maybe that fixed the problem? When I run my game on android, I get this warning:
W 0:00:02:0196 set_icon: Icon not supported by this display server. <C++ Source> servers/display_server.cpp:320 @ set_icon()
Maybe this is the cause since it comes from the same source script that caused your issue?
I guess it could be related, but I have no means to check android version.
Godot version
v4.0-alpha2
System information
Windows 10 64-bit, GPU: NVIDIA Geforce GTX 1650 Ti, CPU: AMD Ryzen 7 4800H
Issue description
I am porting my game to mobile devices. I need to make a button that would trigger a specific action on pressed. The
action
property seems to do exactly that. And it worked on PC! (withemulate_touch_from_mouse
enabled) But on mobile, it doesn't work. It doesnt trigger the action when pressed. Nothing.Steps to reproduce
See above
Minimal reproduction project
No response