We all know how to add static models to scenarios, but how to add animated models to scenarios?
After two days of exploration, I finally found a solution.
In fact, this method is very simple, but for those of us who are new to the torque engine, there are many detours,
I am here to record my journey and hope that the future will not take any detours.
Let's get down to the next step:
1. Create an animation and export the DTs model.
2. generate a new script file, such as ma1.cs, in the./GAME/Server Directory.
3. write the script code to create an animated static model 1 datablock staticshapedata (ma1data) that can be edited in the editor)
2 {
3 Category = "Misc ";
4 shapefile = "~ /Data/ma1.dts ";
5 isplaying = 1;
6 };
7
8 function ma1data: Create (% db)
9 {
10% shape = new staticshape (){
11 datablock = % db;
12 };
13 // % shape. playthread (0, "flow ");
14 missioncleanup. Add (% shape );
15 return % shape;
16}
17
18 function ma1data: onremove (% This, % OBJ)
19 {
20 if (% obj. Client. Player = % OBJ)
21% obj. Client. Player = 0;
22}
4. Add a line to function onservercreated () in the./GAME/Server/game. CS file:
Exec ("./ma1.cs ");
5. Run EXE to add a new model in the map editor. The ma1 model is located under shapes/MISC /.
6. After adding the model, the model does not automatically play the animation. You can run the m1.playthread (0, "run") command on the console ");
You can see the animation. Of course, the M1 here should be replaced with the name of your own model, and the run should be replaced with your animation name.
7. Although we can see the animation, we hope that it will be automatically played when we first enter the scene, and players will not be able to play commands on the console.
Don't worry. We need to add a code in function loadmymission () of the./GAME/Main. CS file to automatically: % M1 = nametoid ("M1 ");
If (! Isobject (% M1 ))
{
Echo ("scene error: cocould not find M1! ");
}
Else
{
% M1.playthread (0, "run ");
}
Congratulations, all the work has been done. Now you can reload the level to see the results of your efforts.