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?
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 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.
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.
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.