![]() |
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: http://i.imgur.com/OaW70.png Now, we can solve for those values pretty easily using simple trigonometry. http://i.imgur.com/tujUf.png 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: http://i.imgur.com/qh99b.png Hope this helps. |
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.
|
That formula helps alot :) thx tig
|
| All times are GMT +2. The time now is 08:23 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.