How do I modifie CustomMovement speed and rotation

  • Hi, I want to set a maximum speed to my player (a submarine) but I can't figure out how. I modified the "CustomMovement: Set speed" but it doesn't go right. Is there an easy way to do this?

    Also, when I release the accelerate button, there is a distance interval where the player is decelerating and then stops. If I rotate the player (to the left or right) in this distance interval he will not change his liniar trajectory. Is it possible to influence that just a bit with the left and right buttons?

    Thanks in advance

  • Could this solve your problem?

    I added maxSpeed variable and additional condition on 1. event

  • Hi razorMonkey, I just tried what you said. The player have a maximum speed now but it doesn't change his trajectory when I press left and right buttons. Can you drop the .capx here? ... maybe I've done something wrong, I'm not good at reproducing .

  • Sorry, I just took care of maximum speed. Now I will take care of the angle of motion.

    Can you drop the .capx here? ...

    No. That would be too easy

    As you can see on the picture, I added two new actions in line 5 and 6 that will take care of the angle of motion.

    Now if you wish that angle of motion follows smoothly angle of submarine rotation it should be the same as rotation of submarine (like in this example, 125). If you want some inertia you should lower it and it will feel like drifting with car. If you make it higher it will act strangely. Try to play with it to get the result you like.

    EDIT:

    also I would suggest that you add dt to acceleration and deceleration, otherwise it will act differently with different framerate

    EDIT 2:

    just ignore line 2, I put animation speed by mistake

  • Hi again, I modified like in the image above and it works to a point where ... if I accelerate and rotate to a certain degree the player continue to go in that direction but facing the wrong way ... I don't know if I explained corectly , sorry for my bad english.

    If I add dt to acceleration (250 * dt) and deceleration (-250 * dt), it's not moving at all. I did something wrong I think.

  • I see where could be the problem. If your speed is greater than max speed he will not add enough additional speed to your direction. So I tried with different approach, it seems to work now.

    So instead of subevent in line 2 I added new event in line 3.

    As for adding dt in acceleration and deceleration, my mistake, it seems Custom Movement behavior already incorporates DT in acceleration so ignore my advice here

    (but you will need it for any movement you will be coding on your own)

  • Thanks man, you helped me alot.

  • But does it work now? Or do you thank me just to be polite?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, it works, I assume you test it to

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