0 Favourites

How do I create this movement

  • I am trying to make this movement but I can't figure out.

    It always go to a diagonal not in a circle move.

    I believe I need to use cos and sin but I don't know how.

  • Check this post :

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Construct's coordinate system is a bit unusual, but you are on the right track with sin/cos.

    You can use cos(angle) to get the horizontal offset and sin(angle) for the vertical offset. Put them together and you have an x,y coordinate for your sprite. Construct uses clockwise angles in degrees, so your A point is actually at 90 degrees and the B point at 180 degrees. If you set your sprite to cos(90),sin(90) it will be at the A point. Set it to cos(180), sin(180) and it will be at the B point. Note that sin/cos return values between +1 and -1. By multiplying the values you can make the circle larger or smaller: cos(90)*50, sin(90)*50 will be on a circle with radius of 50 pixels for example.

    To get some movement you need to animate between those two angles over time. I.e. calculate the position for angle=90..91..92..93 and so on until you reach 180. Construct has an anglelerp function to help you with that. You would stick that inside your equation like this and update your sprite position every tick: cos(anglelerp(STARTANGLE,ENDANGLE,CURRTIME))*RADIUS, sin(anglelerp(STARTANGLE,ENDANGLE,CURRTIME))*RADIUS

    The remaining task is to update the CURRTIME variable so it goes from 0 to 1 over the course of time. You can just declare a variable in the event sheet that starts out at 0 and then every tick increase it by "dt * SPEED". With SPEED=1 it would take 1 second to move from A to B. With SPEED=1/4 (that's 0.25) it would take 4 seconds to travel that distance.

  • Cross_

    Your explanation is very detailed but I couldn't follow it.

    I was able do it on my own in a different manner.

    Take a look:

  • Nice.

    One thing to keep in mind: the duration of "Every tick" can change. You should not add 1 every tick, instead you need to multiply it with dt so the object moves smoothly on slow & fast computers: "Add 100*dt to Startangle"

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
233 22,241
TiAm's avatar
TiAm
Unread hot topic
99 10,126
karshinkoff's avatar
karshinkoff
Unread hot topic
0 Favourites
Path Movement Behavior
98 52,468
R0J0hound's avatar
R0J0hound