Forum

> > CS2D > Scripts > simple vector
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch simple vector

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt simple vector

EnderCrypt
User Off Offline

Zitieren
hi
i would need some help
i want to use player (id,"rot") to figure out the x and y in that direction 10 pixel away

i know its sin and cos... but how

thx

alt Re: simple vector

Flacko
User Off Offline

Zitieren
Take the player rotation and substract 90, convert that value to radians using math.rad()

The target x position will be player(id,"x")+math.cos(angle)*length.
Where angle you use the value you got before, and length should be de distance you want from the player's position in pixels (10 in your case).
Likewise, the y formula is player(id,"y")+math.sin(angle)*length

alt Re: simple vector

DannyDeth
User Off Offline

Zitieren
A basic example, explaination by Flacko up there:
1
2
required_x = player(id,"x")*math.cos(angle)*10
required_y = player(id,"y")*math.sin(angle)*10
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht