AIPlayers not rendering
by Todd Stafford · in Torque Game Engine · 07/19/2007 (5:48 am) · 4 replies
I wrote code awhile ago to spawn an AIPlayer whenever I press the 'n' key, however now their shapes are not rendering. When I pull up the editor (F11) I can see their little red diamonds where they should be but their shapefile is simply not rendering. From what I've read this is normally caused by the shape file being invalid, however I am using the defaulty blue player body.
The other static objects and buildigns I have in the map render fine and the player model (which uses the same PlayerBody datablock) also renders perfectly.
Any advice would be greatly appreciated.
function spawnPlayer(%val) {
if (%val) {
new AIPlayer(Bob) {
datablock = PlayerBody;
position = LocalClientConnection.camera.getPosition();
};
MissionCleanup.add(Bob);
echo("Bob created: " @ Bob.getId());
}
}
MoveMap.bind(keyboard, "n", spawnPlayer);
datablock PlayerData(PlayerBody) {
renderFirstPerson = false;
shapeFile = "~/data/shapes/player/player.dts";
};The other static objects and buildigns I have in the map render fine and the player model (which uses the same PlayerBody datablock) also renders perfectly.
Any advice would be greatly appreciated.
About the author
#2
07/19/2007 (7:56 am)
I have mutliple datablocks that are of the type "PlayerData" but none that have the same name as "PlayerBody"
#3
07/19/2007 (8:20 am)
You appear to be directly spawning the AI in your keypress handler which probably means that you are spawning your AI directly on the client rather than on the server where it should be done. Consider making a commandToServer() call in your keypress handler to a function on the server that does the actual spawning.
#4
And added teh following server function to the server code
However the behavior is still the same, Bob appears in the where the camera is and is invisible.
Thanks for the suggestions so far.
07/19/2007 (8:51 am)
I changed the code in "client/default.bind.cs"function spawnPlayer(%val) {
if (%val) {
commandToServer('SpawnAI');
}
}
MoveMap.bind(keyboard, "n", spawnPlayer);And added teh following server function to the server code
function serverCmdSpawnAI(%client) {
echo("serverCmdSpawnAI");
new AIPlayer(Bob) {
datablock = "PlayerBody";
position = localClientConnection.camera.getPosition();
};
MissionCleanup.add(Bob);
}However the behavior is still the same, Bob appears in the where the camera is and is invisible.
Thanks for the suggestions so far.
Torque 3D Owner mb