0 votes

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 - https://drive.google.com/file/d/18vvgg6bjbzK523dK7AXYNDtCT73fhtYK/view?usp=sharing

Godot version 3.4.2
in Engine by (60 points)

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)

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.

Thanks for the help but I need a better suggestion.

you are welcome

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.