[w]tech combines next generation technologies like full dynamic lighting, voxel based terrain and bullet physics, which are brought to you via a self-explanatory user interface. We are thinking in innovative ways to combine the available technologies and ideas to an edgeless package. Visit wtechportal.com to get more information about the newest features integrated into [w]tech!
Now the shooting, killing, racing, jumping and running can finally begin.
Posted by unrealer2 on Aug 23rd, 2011
How can we force something to move or interact with the player? Since we can't just say it out, we have to tell the computer what it has to do on other ways. That it is: We have to write a script. Therefore we decided to use AngelScript as language because of the great support and a c++-like structure.
One is the GlobalScript, and the other one is the ContentMark-Script.The difference between them is that while ContentMark-Scripts are linked to a ContentMark on which they operate, GlobalScripts haven't such an anchor.
GlobalScripts are meant to be used as scripts which operate on the whole level, or to control the players. You can, though, build the same functionality of a ContentMark-Script into a Global-Script, but this leads to trouble: You'd have to register every single new instance there. This makes the script unusable for other levels and also it leads to much more complicated code than simply using a ContentMark-Script. As said above, ContentMark -Scripts are linked to a ContentMark after placing and can be accessed from inside. This way the same script can be used over and over again.
Now we want to show you, how you could implement a simple CM-Script which just rotates the given ContentMark. To do that, we have to create a new script-file in our browser:
That done, we can double-click our new file and the (rather simple) code-editor will pop up, waiting for us to get filled with code:
This is the basic layout of every Script-File:
Since we already called that script "SimpleRotation" we want it to do exactly that.
We'll surely need the Tick() -Function, so here we go:
As always, Tick() is getting called every frame of the engine when wanted. Makes it just perfect to animate stuff fluently. I also have to mention, that we are running the script-engine on it's completely own thread. That means that rendering-speed and script-speed aren't the same!
Back to our script now. We want our thing to rotate.To do this, we need to get access to the ContentMark we are linked to. This is done via the "GetCM()"-Function.
The call might look like this:
And hey! Our script is ready to get compiled and linked!