Scripts / Entity Orientation Again

Author
Message
kehagiat
11
Years of Service
User Offline
Joined: 16th Jul 2013
Location:
Posted: 12th Jun 2014 18:50 Edited at: 12th Jun 2014 22:51
We recently had a discussion regarding access to entity orientation. While this is not directly provided by FPSCR in its current implementation, I will present a workaround which can give us the orientation info. The workaround is not foolproof, but it may be useful in some cases. In the following presentation I use the details of my own implementation (it is attached for download, see end of message) which certainly NOT the most elegant one possible (any improvements by others will be quite welcome).



I have defined a new Lua table, which I call _Entity (NOT g_Entity!!!) and use it to store several pieces of info which are not included in g_Entity. So I have two fields called _Entity[e]["xold"] and _Entity[e]["zold"]; they include the (x,z) coordinates of the entity at the previous engine cycle. I also have, as will be seen presently, another field called _Entity[e]["Angle"], which contains the entity's current orientation.



Suppose (THIS IS CRUCIAL!!!) the entity has now moved forward and its current position is given by g_Entity[e]["x"] and g_Entity[e]["z"]. Then in the entity's main script I include the lines







and this does it (if you do not see the trigonometry, I will be happy to explain).





Having the Angle information allows us to do some fun things. You can see two examples in the following videos.



In the first video the agents walk so as to form in a line in front of the player. The line is situated relative to the player's position, so when he moves, the agents will also move and reform the line relative to the new position.



https://www.youtube.com/watch?v=Lijz0ZTmtCo&feature=youtu.be



In the second video the agents follow two rules.

The first rule is that they try to stay inside a square, and when they get out of it, they turn around to reenter.

The second ruleis this: when inside the square, each agent tries to align with his nearest neighbor. The result of this is that eventually they all take the same orientation (which they maintain as long as they are inside the square).



https://www.youtube.com/watch?v=DxeZbDnq12g



I have written a little toolbox, which I call Direction Tools v.0.1. It can be found in the attached zip file. To install just copy the contents into your FPSCR 1.0071 installation, BUT!!!! first READ the DirToolsReadme.txt file included in the zip.



Thn



PS: I repeat that the above approach will NOT work always and I am still looking for a really foolproof solution or, even better, a function GetAngle(e) in the next FPSC-R release!!!

Whereof one cannot speak thereof one must be silent

Attachments

Login to view attachments
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Jun 2014 19:36
awesome work!

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11

Login to post a reply

Server time is: 2024-12-22 05:11:58
Your offset time is: 2024-12-22 05:11:58