Control single sprite with two thumbsticks

Just started using Construct 2? Post your questions here

Post » Wed Sep 10, 2014 10:53 pm

Hello! This is my first post after playing with Construct 2 for a little bit. I'm really impressed how quickly I was able to get up and running and throw together quick demos. I've read a few tutorials but I can't quite seem to get my head around this problem and wondered if anyone had any ideas.

The game I'm making has two thumbsticks which I want to use to control a horizontal 'plate'. I'll only really use vertical controls on both thumbsticks, where the goal is to balance something on the plate. The left thumbstick should control the left hand side of the plate and the right thumbstick controls the right.

What I think I need is some way to semi-independently control each 'end' of the plate, but can't quite fathom how to do that. Suggestions welcome!

Thanks!
B
5
S
1
Posts: 3
Reputation: 393

Post » Thu Sep 11, 2014 7:14 am

If the objective is to keep things balanced on the plate you could set the plate so it rotates/falls left or right randomly then have the player react by correcting the plates balance with the sticks.

you could try something like
Code: Select all
Every Tick -------------- Plate Rotate random(-10,10) clockwise
that way the plate will rotate either 10 degrees left or right max. then check if the plate has fallen by doing something like
Code: Select all
Plate angle >= 10
or
plate angle <= -10 -------------- destroy plate


I imagine you could even do this with the physics behavior and every tick check the plates angle and position however you'd probably need to do a lot more tweaking.

As far as working with the joysticks goes, just add the gamepad input object into your project then go to Compare axis and check both their Y axis like so,
Code: Select all
Left analog Y axis = 100
Right analog Y axis = 100


Hope it helps!
B
13
S
2
G
1
Posts: 47
Reputation: 1,211

Post » Thu Sep 11, 2014 9:41 am

Thanks for the reply. I don't actually want to control just the angle as it feels un-natural. The control I want is what you would have if you had one hand/finger under each end of the plate. You could lift the plate up vertically if you push both fingers together, and down if you pull down. But if you push one slightly up it would tilt that end of the plate. So it's a little more complicated than just rotating around an axis in the middle I think.
B
5
S
1
Posts: 3
Reputation: 393

Post » Thu Sep 11, 2014 8:57 pm

You could create two "Finger"-sprites which are controlled by the thumbsticks and have the plate either pinned by location only, or via physics revolute joint, or just set the angle of the plate to angle(fingerleft.x,fingerleft.y,fingerright.x,fingerright.y)

Issue with the first two solutions is ofcourse that the plate becomes shorter in the horizontal direction when the angle get's bigger, but there are multiple ways to take that into account..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Sep 13, 2014 10:39 am

Thanks! I'll take a look at that.
B
5
S
1
Posts: 3
Reputation: 393


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 6 guests