Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.