How do I Tandem rotor helicopter movement

0 favourites
  • 11 posts
From the Asset Store
***** Fully animated helicopter game asset pack *****
  • 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.

  • 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:

    - Sprite: set angle to: "Self.Angle+?"
    [ul]
    	[li]Sprite: move forward: ?[/code:f76tkgc4][/li]
    [/ul]For the right key, it would be the same, just "Self.Angle[b]-[/b]?".
    
    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.
  • 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.

  • 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).

  • 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.

  • Thanks so much!!!

  • Donkeykong12

    Did it work for you?

    Did I understand you correctly?

  • 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!

  • 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. :)

  • Thanks for the capx, really cool.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • randomly

    can i get this capx file, i can't find the file that you have attached since it has been removed.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)