Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Slow down Joystick input

Author
Message
Olde Worlde Illusions
2
Years of Service
User Offline
Joined: 10th Oct 2021
Location:
Posted: 5th Dec 2021 04:32
Here is code I am using for input:

The issue is cursor.x is incremented very very quickly. Is there some way to make it so it only increments each time the stick is pushed instead of held?
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 5th Dec 2021 05:18 Edited at: 5th Dec 2021 05:18
when you push any joystick it equals something around 8 or -8

What I do is say

if(joyX = 3)
then this happens
endif
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 5th Dec 2021 05:34 Edited at: 5th Dec 2021 05:48
Quote: "when you push any joystick it equals something around 8 or -8"
huh?

@OWI, that's going to be tricky with a virtual joystick because they emulate digital joysticks with a range between -1.0 and 1.0 but the idea would otherwise be along the lines of :

note the value of GetVirtualJoystickX() when you release it where it gradually returns to center/0. so, just because you "released" it doesn't mean it's 0/centered/ready for another tap.

but, to detect a move in either direction, you'll need to compare it to "unmoved", somehow.

that being said, if you're intent on using a vjoystick to move the cursor, you may simply want to put a timer on it to "slow it down":
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 5th Dec 2021 05:54
Quote: "that's going to be tricky with a virtual joystick because they emulate digital joysticks with a range between -1.0 and 1.0 but the idea would otherwise be along the lines of :"


Whoops lol, That is correct.

I am always thinking a real joystick, sorry.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 5th Dec 2021 07:26
Timers are a Programmers Best Friend...
In fact I'd say that the MOST important Procedure to Memorise is:



Using Timers to limit how often you "Run" Components will ensure that updates are Consistent., thus you can adapt update values based upon said Timer Period.
Esp. if we ALWAYS Multiply by the Duration between the Timer Calls.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 5th Dec 2021 11:04
Quote: "Timers are a Programmers Best Friend..."


Agreed.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-04-24 16:59:40
Your offset time is: 2024-04-24 16:59:40