lengthdir_x and lengthdir_y in construct 2?(Solved)

0 favourites
  • 6 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hello everyone!

    I am trying to rebuild some things into construct from game maker pro.

    I use lengthdir_x and lengthdir_y in GM for some functions in my code. How would I achieve this using construct 2?

    here is how gamemaker explains its purpose:

    Description

    This function seems confusing at first, but it's not really. It is used to get the x component of a position "len" pixels from the starting point and in direction "dir". Imagine a circle around your instance, then imagine a point anywhere on that circle. To move to that point we need to move the object so many pixels in that direction... so this function (when used with lengthdir_y) gets the position of that point on the circle to be used in code by the instance. See the image below for details:

    Source:

    Game Maker Docs

  • From the look of it, it seems that lengthdir_x(len, dir) and lengthdir_y(len, dir) are basically cos(dir)*len and sin(dir)*len.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wouldn't using move at angle work?

    depending on what you use the expressions for..

  • Perfect, I think both options will work for what i need. TY for the quick response. I just love the community here!

  • From the look of it, it seems that lengthdir_x(len, dir) and lengthdir_y(len, dir) are basically cos(dir)*len and sin(dir)*len.

    so if i use cos(90)*len(1) it will move me down 1 pixel from my current point of reference?

  • Sorry if it was ambiguous, len here was a variable (from the Game Maker Docs). Here's what it look like with the value 90 for "dir" and 1 for "len".

    lengthdir_x(1, 90) = 0

    cos(90)*1 = 0

    lengthdir_y(1, 90) = 1

    sin(90)*1 = 1

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