How do I normalize a vector?

Get help using Construct 2

Post » Wed Mar 01, 2017 6:24 pm

So how can I normalize a vector like this?

X = (target.x - player.x)
Y = (target.y - player.y)
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Wed Mar 01, 2017 6:49 pm

You first find the length and divid both values by it.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Wed Mar 01, 2017 7:51 pm

(probably a dumb question)

is that the same as
Xnormalised = cos(angle(player.x,player.y,target.x,target.y))
Ynormalised = sin(angle(player.x,player.y,target.x,target.y))

?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 01, 2017 9:28 pm

99Instances2Go wrote:(probably a dumb question)

is that the same as
Xnormalised = cos(angle(player.x,player.y,target.x,target.y))
Ynormalised = sin(angle(player.x,player.y,target.x,target.y))

?


I think yes, I used that formula to get what I wanted.

Thanks both.
B
6
S
2
Posts: 61
Reputation: 1,099


Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, Shenkai the ssj and 24 guests