Joystick Controlled Cube

I made a project where you use a joystick to rotate a cube around. Link: Game | Desmos

The problem is, when I keep the joystick in one place, it sets the joystick position to 0,0. This is to make the joystick snap back to the center. Only problem is, it still gets SET to 0,0 when the player just stops moving the joystick, but still has it pulled to where it is. This makes it so the cube stops rotating even though the joystick isn’t visually at 0,0. Any ideas on how to fix this?

I didn’t study the situation to understand how to fix the problem …
but the graph is awesome!!

What is the purpose of a and b if you already have a_bold and b_bold?
I don’t really understand how to fix it either, but I think its something to do with a = a_bold and then b = b_bold

I believe the root of the problem is detecting whether or not the user’s mouse is in the “clicked” state on the joystick. In coding, this is usually defined as something like:

if (isClicked=true): {

   a=1

else (): {

   a=0
};


However in Desmos, this would likely either require an external script or a point that is both clickable and draggable

It was supposed to be a_old and b_old, idk if i accidentally typed that wrong, but they are to find a and b’s previous position, so I can detect whether or not a and b have moved in the last L seconds. I did look through it and I think my problem is that to make the joystick snap back to the center, I made it so once it detects a and b not moving, it sets a and b to 0. But since the user would still be dragging the point around they don’t visually go back to 0.

I agree with Loumen, you can’t detect if a point is being interacted with in Desmos without external javascript.

I think @XenoShrimp may have been on the right track. If you use the ticker and capture coordinates, and compare the distance from the current coordinates to the captured coordinates, you could determine whether it is updating (i.e. being interacted with) without needing JS.

That’s what he did, but it doesn’t work.

Ah, maybe needs a second offset point that gets set if the coordinates suddenly change to (0,0), so that the joystick “center” becomes the release point.

Good idea! I will try that soon! But how will we know if the user just stopped moving, or actually released it?

I think you’d have to play around testing, but my approach would be if there’s a significant change in distance to the current offset center in an extremely short time. What that specifically would be I don’t know.