lengthdir_x and lengthdir_y in construct 2?(Solved)

Get help using Construct 2

Post » Tue Nov 10, 2015 5:15 pm

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
Last edited by mordiaky on Tue Nov 10, 2015 6:00 pm, edited 1 time in total.
B
8
S
1
Posts: 74
Reputation: 725

Post » Tue Nov 10, 2015 5:18 pm

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.
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Tue Nov 10, 2015 5:19 pm

Wouldn't using move at angle work?

depending on what you use the expressions for..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Nov 10, 2015 6:00 pm

Perfect, I think both options will work for what i need. TY for the quick response. I just love the community here!
B
8
S
1
Posts: 74
Reputation: 725

Post » Tue Nov 10, 2015 8:56 pm

Magistross wrote: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?
B
8
S
1
Posts: 74
Reputation: 725

Post » Tue Nov 10, 2015 9:16 pm

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
B
74
S
31
G
26
Posts: 994
Reputation: 20,198


Return to How do I....?

Who is online

Users browsing this forum: arvivlx2, Meqara and 8 guests