Forum

> > CS2D > Scripts > simple vector
Forums overviewCS2D overview Scripts overviewLog in to reply

English simple vector

4 replies
To the start Previous 1 Next To the start

old simple vector

EnderCrypt
User Off Offline

Quote
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

old Re: simple vector

Flacko
User Off Offline

Quote
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

old Re: simple vector

DannyDeth
User Off Offline

Quote
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview