Game Development Community

Make a TSStatic Player Object to move forward

by Pam Shill · in Torque Game Engine Advanced · 12/01/2009 (12:40 pm) · 3 replies

Hello Everyone. Can someone throw some light on how to do the following. I believe it should be easy.

I am using TGEA 1.8.1. In the stronghold demo, I used the world editor creator to drop a TSStatic Player entity from the menu under StaticShapes and have given it a name. Now I want this entity to move forward upon some action through script.

I see in the scriptsAndAssets/data/shapes/player there is a player.cs file, player.dts file and many .dsq files which came already. So I think with these files animations can be possible. But I am not sure how to call these to have my required animation(moving forward) happen.

I searched through the forums but I am not able to figure out how to do it.

Thank you very much in advance. Hoping to hear some ideas.

#1
12/02/2009 (3:53 pm)
The problem is that TSStatic objects, as the name implies, are designed to be static. They can't, by default, move, animate or collide. Is there any reason you want to make your player a TSStatic instead of a Player?
#2
12/02/2009 (6:19 pm)
Pam,
Are you attempting to put AI players in, (baddies to populate your mission), or are you attempting to change the player model? Either way TSStatic is more for environment and unmoveable objects, as Daniel said, they dont' move around, animate or collide.
#3
12/06/2009 (12:31 pm)
I had the same issue when I first began working with torqueScript. As Rich and Dan said, TSStatic is for static objects. If you are using the StrongHold demo from 1.8.2 the code below is the result of me asking the same kind of questions.

Still not very experienced, and still learning what everything means, I used the following script to put an AI player on the level.

// Create the demo player object
   %player = new AiPlayer() {
      dataBlock = DemoPlayer; //defined in /scriptsAndAssets/scripts/aiPlayer.cs
   };
   MissionCleanup.add(%player);//I think this is what actually adds the player to the view
   %player.setShapeName(%player.getID());/*sets the name of the player(the little green text above the ai player) to its, ID, this makes it easy to do things in the console based on an ID*/
   %player.setTransform(%spawnPoint);// if you don't define the initial transform I am fairly certain that it will put your AI in the middle of the board which is no where near where the 1.8.2 stronghold demo put you the player (451.806 296.687 230.637 is where the you the player are)
   return %player;//don't know if this is needed or not.
}

function add1()//this function was a quick and easy way for me to keep adding aiplayers... I just open the console with the tilde and type add1. It calls the spawn function above... kinda like a shortcut. I have even bound this to the "t" key so that I don't even have to open the console up... but for some reason it adds 2 new korks...
{
   AIPlayer::spawn("451.806 296.687 230.637");
}

I put the above code into a file called addNewKork.cs and put it in a testingScripts folder. then in my scriptsAndAssets/server/scripts/game.cs line 59 I added the exec function to "import" the code from my addNewKork.cs file.
exec("testingScripts/addNewKork.cs");

I hope this helps you. And if my assumptions or code is way off, please correct me as I am very new and may be wrong :)