Control and curves

Hello! I’m totally newbie.
Thank you in advance for answers!
I need to make a control system with dragging fingers on a screen and curves.

  1. How to make curves that depends on where I hold my finger on a screen in exact time? Making curves isn’t really hard, but how to make them change due to player’s act?
  2. How to separate code in to parts for the purpose of control. Like:
1 Like

Have you read the manual relating to input in Defold? It describes mouse and touch input as well as the pressed and release events.

3 Likes

If you want to draw a preview of a player’s trajectory from an input I suggest you to use physics formulas, that depends on the type of the physic used in your project. Once you got an appropriate function that returns the position of a player after t time, you can create multiple points in the given position, each one in a fixed time step.
For example if you’re using cinematic with a g gravity:
finalX = initialX + initialVelocityX * time
finalY = initalY + initialVelocity * time - g * (time * time)
To make sure you undestand, or that this is an appropriate method look for your needed formula.

2 Likes

Well, I’ve read, but maybe missed something. Thanks! I’ll check this out

1 Like

Thank you very much, especially for the example!

2 Likes