Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-13-2011, 10:13 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Vecx and Vecy Explained

Understanding vecx and vecy has been a common question for beginning scripters in GScript2. I wanted to make this post to help put some of those questions to rest.

On Graal, we use 4 directions: 0, 1, 2, 3 (up, left, down, right respectively). Put simply, the purpose of vecx(direction) and vecy(direction) is to give a change in x or y if an object were to move by 1 unit in the direction given.

So, for example, if your direction is 1 (that is, left), then vecx(1) = -1 because you would need to move -1 units in order to move left by 1 unit on the x-axis. Similarly, vecy(1) = 0 because if an object is moving left, then its y does not change.

Now we understand what values we should be receiving in different cases. I have outlined them here for you:


Now, we can solve for those values pretty easily using simple trigonometry.

If we refer to a complete circle, you may notice that on intervals of pi/2 we see the values of vecx and vecy we are trying to find.

So, using elementary trigonometry, we find vecx and vecy are actually:


Hope this helps.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:55 PM.


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