Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SDGN16 |
I’m trying to turn the object right or left by scrolling, but I couldn’t do it for the other side.
func _input(event):
if event is InputEventScreenDrag:
if event.relative.y > 0 or event.relative.x > 0 or event.relative.x < 0 or event.relative.y < 0:
self.rotate_x(+.03)
How do I do the flipping for both sides?
video - 6546463.mp4 - Google Drive
if event is InputEventMouseButton:
if event.pressed:
touch = event.position.x
if event is InputEventScreenDrag:
drag = event.position.x
if touch - drag > 10:
turn right
ramazan | 2021-12-27 10:09
no I did not understand.
SDGN16 | 2021-12-27 10:16
deniyorum.
SDGN16 | 2021-12-27 10:17
now i hope i did explain
var touch = null
var drag = null
if event is InputEventMouseButton:
if event.pressed:
touch = event.position.x
if event is InputEventScreenDrag:
drag = event.position.x
if touch - drag > 10:
turn right
if drag - touch > 10:
turn left
ramazan | 2021-12-27 10:19
seems to work but wrong
var touch
var drag
func _input(event):
if event is InputEventMouseButton:
if event.pressed:
touch = event.position.x
if event is InputEventScreenDrag:
drag = event.position.x
if touch - drag > 10:
self.rotate_x(+.03)
if touch - drag < 10:
self.rotate_x(-.03)
SDGN16 | 2021-12-27 10:23
look again . what is wrong
ramazan | 2021-12-27 10:27
touch - drag > 10
drag - touch > 10
ramazan | 2021-12-27 10:33
en iyi dosyaya bakın
rotate.zip - Google Drive
SDGN16 | 2021-12-27 10:41
extends StaticBody
var touch
var drag
func _input(event):
if event is InputEventMouseButton:
if event.pressed:
touch = event.position.y
if event is InputEventScreenDrag:
drag = event.position.x
if touch - drag > 10:
self.rotate_z(-.03)
if drag - touch > 10:
self.rotate_z(+.03)
ramazan | 2021-12-27 11:14
I tried, it works, but it needs details and will cause trouble in the future. Add a 2d node to the cube scene and make it transparent. Add input event to 2d node and check from there. Just a suggestion.
ramazan | 2021-12-27 11:32
Thanks for the help but I need a better suggestion.
SDGN16 | 2021-12-27 11:40
you are welcome
ramazan | 2021-12-27 12:11