Hi, I'm doing research and trying to conceptualize a vertical mobile game that has like an Intellivision disc. Basically I'm trying to think of how you would control like a wheel with touch input.

I'm just a little confused where I would even start with the logic. I'm imagining following the mouse, but I don't want to be able to slide from one side to the other like a joystick.

I'm gonna try to do all the research on touch controls in Godot and whatever tutorials I can find, but man it's a nightmare, so if anyone has some words of wisdom, I'd hugely appreciate them.


  • xyz replied to this.

    NJL64 I'd approach it as follows, regardless of is it mouse or touch. If the mouse is down, at each mousemove event get the direction vector from wheel center to current mouse position as well as the same direction vector for the position at previous frame. Now simply rotate the wheel by the angle difference between those two vectors. To prevent funky behavior if the mouse is near the wheel center, simply do nothing if the mouse is inside certain radius around the center.

      xyz Thank you. This is very helpful to helping me visualize an approach even though I'm still new to this. Like, right now I plan to study vector math more, as I've only been using it as it comes up in tutorials. Whereas before, I wasn't even sure how to conceptualize any form of logic to potentially achieve the result I want, but vector math is the proper logic my brain is looking for, or the key to that logic if you will.

      By the way, what do you mean by "the position at previous frame"?

      • xyz replied to this.

        NJL64 By the way, what do you mean by "the position at previous frame"?

        I meant mouse position at previous frame.
        Here's a quick example:

        extends Sprite2D
        
        const RADIUS_MIN = 20.0
        
        func _input(event):
        	if event is InputEventMouseMotion and event.button_mask & MOUSE_BUTTON_MASK_LEFT:
        		var direction = event.position - global_position
        		var direction_prev_frame = event.position - event.relative - global_position
        		if direction.length() > RADIUS_MIN:
        			rotate(direction_prev_frame.angle_to(direction))