How do I move character a user defined set distance?

0 favourites
  • 5 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • Hey

    searched but cant find a way of moving a character/sprite a distance as defined by user input.

    eg. move character 5 units left, then turn through 90 degrees, where 5 and 90 are values provided by the user.

  • First we would need to know what a unit is and how you define it?

    Secondly, What behaviour are you using or do you want to use for the player movement?

  • thanks for quick response, using the distance function i have a text box that displays the distance between two objects, i assume it is in pixels, doesnt really matter as i just need the character to move in a straight line for half the measured distance , then rotate through an angle of say 90 degrees. i thought of using custom movement?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure what it is exactly you want..

    But you can get the angle between two objects with

    angle(object1.x,object1.y,object2.x,object2.y)

    the distance with

    distance(object1.x,object1.y,obect2.x,object2.y)

    You could use the bullet behaviour, like in the moveto example, or the third party moveto-behaviour or litetween..

    To get the point halfway you could use lerp

    so x would become:

    X = lerp(object1.x,object2.x,0.5)

  • thanks i will look into those.

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