How do I Tandem rotor helicopter movement

Just started using Construct 2? Post your questions here

Post » Thu Oct 06, 2016 10:34 am

Hey. Is there a way to make two button movement to control a sprite. Like left key would rise it and rotate clockwise, and right key would rise it and rotate counter-clockwise. Im having trouble getting it move up and down in the angle of the sprite.

Thanks so much.
B
4
Posts: 11
Reputation: 220

Post » Thu Oct 06, 2016 2:48 pm

Well, of course that is possible.

If I understood you correctly, you have a single sprite which will go up and rotate clockwise when you hold the left key and go down and rotate counter-clockwise when you hold the right key?

I'm a bit confused what your goal is because your thread's title sounds different to what you describe...

I will just guess now that you want the sprite to move in the direction it is facing?
So it does a curve when you hold either key?

Well, if I understand you correctly, this is what you gotta do:

- add the "Keyboard" object
- add two "key pressed" conditions, one for the left and one for the right key.
the actions in the "key pressed" condition for the left key would look like this:
Code: Select all
- Sprite: set angle to: "Self.Angle+?"
- Sprite: move forward: ?

For the right key, it would be the same, just "Self.Angle-?".

Replace the ? with a degree of your favour for the Angle and a pixelamount of your favour, for the movement.
The higher the value, the faster.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Fri Oct 07, 2016 2:53 pm

Sorry for confusing explanation.

I meant a movement like when left key is pressed the sprite goes up and rotates clockwise. When right key is pressed the sprite goes up and rotates counterclockwise. The sprite wound go down when nothing is pressed, like gravity.

The problem I have for example, when left key is pressed and my sprite goes up and rotates. It should move right like it rotates. Like a helicopter moves when its tilted.
B
4
Posts: 11
Reputation: 220

Post » Fri Oct 07, 2016 10:19 pm

Hey @Donkeykong12

I think I start to grasp your idea...
So the left key controls the left rotor of the helicopter and the right key controls the right rotor?
So the longer you hold the key, the higher the throttle of the rotor?
And when you press both keys at the same time, the helicopter will just go straight upwards?

If that's what you're going for, I'll try to setup a little capx to show you how to do it. (If I'm actually able to do it, but it should work).
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sat Oct 08, 2016 12:09 am

Yo @Donkeykong12

I created a .capx for you. :)
Download .capx
When I started thinking about a way to implement what you want, I figured that it would be the easiest way to go with the Physics behaviour.

So I went and added a Physics behaviour to the Chopper. (You can modify the chopper's movement in the air with the Physics's parameters like damping or density).
The way the Chopper gets moved is the following:
I added two ImagePoints to the Chopper's Sprite (which I created just for you, it's ugly I know), one at the left rotor and one at the right.
Now when you press the left key, a Physics force is being applied to the left rotor, towards the direction the Chopper is facing at the moment.
The same is for the right key, just that the right rotor is being affected.

That is basically it. There is much to tweak for you to fit the Chopper's behaviour in the air to your liking. You can do this via these parameters:
Chopper's physics behaviour - parameters:
- Density (affects the general speed of the Chopper, the lower the number the more do the forces affect the Chopper)
- Linear damping (affects the acceleration and deceleration in the air, the higher the number, the faster does the Choppers speed reduce)
- Angular damping (affects the rotation speed, the higher the number, the slower does the Chopper turn)

Event sheet:
- Apply Physics force X at Image Point (X affects the strength of the force, the higher the value, the faster the Chopper will rotate and the faster its speed will increase)
- IF Chopper(Physics velocity < -60) THEN Set Physics velocity to ..., -60 (change 60 to whatever you like, this just ensures that the Chopper can't go up at infinite speed, it basically clamps its horizontal up speed to maximum 60.)

I tweaked the settings so that the Chopper is somewhat controllable, change the settings as you want or implement it in your project if you dig it. You can take my Sprite even if you want. (Though I don't recommend it, it is NOT particularly beautiful. It took 5 minutes to create and that's how it looks like lol)

That's all to say. I hope, I understood you correctly this time. :D
Have fun with this capx.
Last edited by randomly on Sun Nov 27, 2016 6:06 pm, edited 1 time in total.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sat Oct 08, 2016 7:26 am

Thanks so much!!!
B
4
Posts: 11
Reputation: 220

Post » Sat Oct 08, 2016 2:24 pm

@Donkeykong12

Did it work for you?
Did I understand you correctly?
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sat Oct 08, 2016 6:04 pm

It worked perfectly.
But do you know how to make the effect of gravity greater? So the sprite would go down faster.

Thanks for everything!
B
4
Posts: 11
Reputation: 220

Post » Sat Oct 08, 2016 11:15 pm

Glad I helped you.

To increase gravity's effect on the Sprite, you would have to increase its Density.
That would mean though that you would have to tweak the Force applied to the Sprite on key pressing.

You would have to increase the Force so that the Chopper still gets pulled up at an acceptable speed.

You just need to find a good balance between Density and Force.

_____________

I like your game idea, looking forward to see where your project goes. :)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sat Nov 26, 2016 9:17 pm

Thanks for the capx, really cool.
B
12
S
3
G
2
Posts: 38
Reputation: 1,380


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 4 guests