Platform behavior control with gamepad

Get help using Construct 2

Post » Thu May 02, 2013 1:56 am

Hey all,

I just bought a wired Xbox 360 controller to try out with the Gamepad object. It works very well however I've run into a very interesting issue.

I'm trying to get it working together with the platform behavior. The platform behavior is designed for keyboard / binary input - completely stopped or running as fast as possible. This presents some natural difficulties when adding a gamepad controller - of course, it's trivial to just set a threshold and turn the analog stick's proportional input into a binary input - however one sacrifices the fine-grained control that analog sticks provide.

My first thought was to simply set the platformer's max speed to some factor of the analog stick's x-axis. This works well for the most part, however it completely breaks deceleration - releasing the analog stick brings the player to a jarring halt in mid-air as the max speed resets to zero.

Does anyone have any ideas about fixing this?

B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu May 02, 2013 8:03 pm

*bump*
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu May 02, 2013 10:08 pm

you always told me to use variables :)

Then you could do , if the analog stick X-axis is not egal to zero ;
Set max speed to analog stick X-axis

Does that resolve it ?
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Thu May 02, 2013 10:25 pm

@Whiteclaws that doesn't work as zero is just a 'special case' - plus, the game would register a reduced max speed if the stick happened to register a number while snapping back/being released slowly.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri May 03, 2013 12:17 am

hmmm

var constant dec = 0.2 // fiddle to speed
var constant pwr = 10


var speed = gamepad.x * pwr
if (speed < sprite.currentspeed)
{
sprite.currentspeed = lerp(sprite.currentspeed, speed, dec)
}
else if (speed > sprite.currentspeed)
{
sprite.currentspeed = speed
}


ummmm. will that work based on what your looking for; or at least maybe some inspiration to solve your problem. It's not fined tuned too work 100%. I'm just brainstorming.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Fri May 03, 2013 12:30 am

@jayderyu any specific reason you used lerp()? Why not just simple deceleration value every tick?

I see the thought behind that, though, it may just work! hmm...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri May 03, 2013 1:13 am

@sqiddster, I thought it might create a more fluid deceleration that was dt based rather than tick based. If the deceleration was per tick then slower hardware would end up having a deceleration slower compared to the dt already implemented... however I forgot to add the dt modifier.

i'm just trying brainstorm an idea. If it helps get you on the right path the suggestion successful :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests