Move to random point

0 favourites
  • 4 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I would like to implement a movement where the object picks a random point on the screen moves to it and once its there picks another random point. I would also like to speed the object up after each movement. I have been trying to do with with sine waves but can't seem to figure it out. Anyone have any ideas?

  • Its rather easy to do. And can be done several ways, so ill just comment on one of them here.

    If you make an event that triggers every X nr of ticks/Seconds depending on what you like.

    And in there you add.

    Object.X = random(WindowWidth)

    Object.Y = random(WindowHeight)

    Since you want it to jump faster and faster, you can add a global variable called "Speed = 15" which will simulate seconds in this example.

    In the event "Every X seconds" you set the value to this variable:

    Every <Speed> seconds

    ...make object jump

    Then in the end of this you just reduce "Speed" with whatever value you feel like.

    So the complete code would look something like this:

    Global Speed = 15


    Every <Speed> seconds

    Object.X = random(WindowWidth)

    Object.Y = random(WindowHeight)

    Set Speed to Speed - 1 (Will reduce it by 1 second every time it jumps.)

  • Im sorry, while this does actually help a bit i think i was unclear, this seems to make the object jump between 2 point when actually i want it to tween between the two faster and faster with every movement.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use lerp or a custom movement behaviour. I'll give you an example using the custom behaviour.

    var1 = 1

    Trigger once

    ..(set varx value choose (x1,x2...))

    ..(set vary value choose (y1,y2...))

    ..var1 = 0

    var1 = 0

    Trigger once

    ..(create object at x,y)

    ..var2 =1

    var2 = 1     


    ..(accelerate custom movement var3 towards (varx, vary)

    ..add 30 to var3 (adjust the amount here to vary the speed)

    object x = varx   

    object y = vary

    Trigger once

    ..set var1 to 1

    ..set var2 to 0

    ..set var3 to 0

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