How do I: Smoothly, continuously move object to position

From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hi all! :]]

    I don't know if this is even possible. But I have thought a lot about it, and I can't seam to figure it out, so I thought I might ask if anyone else can.

    I'm making a game where you control a spaceship, and I want the spaceship to Follow the cursor around when the mouse is moved.

    Like a Bullet behaviors that has an event that always sets angle to Mouse.X and Mouse.Y.

    Also I'm aiming towards an "Asteroids"-feel to the movement. Meaning that ideally, the ship should accelerate, and decelerate smoothly, and if the cursor is moved, the ship should adjust to the cursors new position. Sort of like a custom movement which has an event that continuously accelerates the ship towards Mouse.X and Mouse.Y.

    On top of this the ship needs to adjust as to "hit" the cursor. All I can make it do is fall into an orbit around it. (which makes sense considering I don't know how to compensate for current speed and angle ).

    If this requires very difficult math or something, I'm willing to google around and try to understand your calculations. But I can't for the life of me figure this out.

    Any help would be greatly appreciated. Even as to say that this can't really be done. Then I would at least be content in giving up.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here you go:

    .capx Download

    I included two variants:

    • a lerp variant which emulates acceleration by using lerp
    • a custom movement variant which is quite complicated because of all your needs ;)

    The .capx is fully commented, I hope you understand everything and I also hope, I understood correctly what you need.

    In case you have questions, don't hesitate to ask.

  • Thats you for taking the time to help randomly. (That's a nice sentence <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing"> ).

    The first example can't account for collisions properly, due to it setting position. (And also didn't have the "Thrusters in space" feel to it.)

    The second movement sometimes didn't move at all for several seconds and didn't hit the cursors position.

    So I couldn't adopt any of those movements directly.

    But I did get a few ideas and learned a few things from them though.

    For starters, even though I had read the whole manual, I had never actually used lerp, and then I guess I must have forgotten about it, Because I just recently "Solved" this by using something like (A*C+B*D)/(C+D) instead of lerp. <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

    Experimenting with your second movement made me get the ideas that I then used to manage to build the movement I was after. In the end though. I systematically replaced all the lerp stuff I had in it. But it was an important stepping stone.

    I provided the "finished product" that I will implement into my game. In case anyone is interested.

    https://drive.google.com/file/d/0B3l68R ... sp=sharing

    Thanks again! <3

  • Do you still have this capx fire shared somewhere? The link above is busted.

    Thanks!

  • fixed the link

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