View Single Post
  #1  
Old 10-08-2002, 11:13 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Newb Gift: Circular Movement

It seems that all the newbs seem to have problems for some reason with cos and sin. I feel it is my responsibility then to provide help and give a quick description. I know this has been covered UBER amounts of time (Maybe this'll get stickied even)

First off, Sin is the opposite angle divided by the hypotenuse. Cos is the adjacent angle divided by the hypotenuse. Perhaps Kai will be kind enough to post his chart up again Using sine (sin) is generally applied to the x value. Using cosine(cos) is generally applied to the y value. When moving around persay a light or something, this is the format you would use:
NPC Code:

if (action)
{ x=x+sin(angle)*distance;
y=y+cos(angle)*distance;
}


The x value gets added to the sin of the angle, then multiplied by the distance from the centre point. It isn't all that hard. Play with it a bit. Use a variable for angle and distance. Try and get things to move on a timeout or whatnot. It'll come in handy. I hope you find use for it and I explained what you did not understand. If you have any other questions, that haven't been answered in EVERY other cos/sin thread, ask away.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote