Joystick problems

Hi there,

I currently have a project where we need to make a automatic obstacle avoiding robot. With the project we need to make it possible for the user to interfere, and control it for a bit in case the robot can't solve it's own problem.

Because of the succes last project with MIT APP INVENTOR and because i really enjoyed it, i wanted to make an app again for the robot. With that I didn't want a standard up, down, right and left button, but instead make it a little more difficult, so i decided to implement a joystick in the project. I've watched a couple video's on how to make an easy one with the canvas and the ball components, so i made this.


I've made 2 balls just to make the joystick look better and the center of the second moves with the drag of the top one so it moves along with it. I've made a block with it where i first of all do - 150 for x and y to make the coördinates like a normal joystick and to do the math to make my joystick stay in a circle, like this.

With that i want to program it so if i move my finger outside the circle it stays in it.

At last I of course set the coördinate back to app inventors canvas by +150 on the x and y again.

My problem is that i'm not able to make the joystick stick inside the circle, so i wonder if anyone could help me.

Hope i explained my problem good enough, otherwise let me know.

greetings,
Brum

1 Like

there is a extension by @Andres_Cotes as this extension is only in appybuilder community so you cant download it so i will send it here - co.com.dendritas.Joystick.aix (18.5 KB)
mods if this is not correct then please hide this post
also see this -

I see you have the Thunkable community open on one of your tabs. Did you take a look at this topic?

No i watched a different one, but i'll take a look at both in a minute, thanks for the help.

1 Like

I see in your dragged event code that you immediately do the move_to block, without first checking if the resulting destination would be out of bounds.

Rearrange your code.

2 Likes