Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 05-13-2011, 11:30 PM
Katie Katie is offline
Registered User
Join Date: Nov 2010
Posts: 5
Katie is on a distinguished road
Send a message via AIM to Katie Send a message via MSN to Katie
This is a good explanation for using vecx and vecy, and I hope it helps a lot of people. I decided to summarize the results for anyone who may need a quick reference.

Reply With Quote
  #3  
Old 05-14-2011, 12:55 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
That formula helps alot thx tig
Reply With Quote
Reply

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 10:35 AM.


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