Game Development Community

H: Object creation runtime Server/Cleint environment

by Richard-HH · in Torque Game Engine · 12/12/2006 (2:06 pm) · 3 replies

Hello Everybody,

maybe im asking the same question the 9862 time, forgive me but search didnt came up with something helpfull so far.

Environment:
TGE 1.5
VisualStudio 2005
A simple map
Dedicated server

What i want to do:
I want to add objects to the world at runtime. These object are predefined in blocks.

• How do i add objects at runtime generally but AVOID relighting?
• How do i add objects at runtime in a Server/Client environment?
• The datablocks should NOT be on the clientsite, they must be on the serverside


If these questions are a pirce of cake, im sorry, but somehow i am a bit lost now how to do this.
It would be nice if this could be done 99% scripted.

Thank you very much for your help and sorry if this was asked a gazillion times before.


Richard

#1
12/14/2006 (7:12 am)
Dts objects dont need relighting. Here's an old post where I describe mounting an object, also shows you how to create an object and spawn it at runtime.

I created a new script called 'myObject.cs' and placed this code in it:

// test shape
datablock StaticShapeData( myObject )
{
shapeFile = "~/data/shapes/player/player.dts";
};

it's the ork model.

then in game.cs at the top do the exec("./myObject.cs"); in its proper place with all the other execs.

then down after the player spawns in CreatePlayer .. at the end of that function add;

%myObject = new StaticShape() {
dataBlock = myObject;
position = %player.position;
};

%player.mountObject(%myObject,2);


This just creates a new Ork model & places at the players position then mounts it onto the players shoulder. :D

What you would probably want to do is create a new function to spawn any object you pass to it. Something like (keep in mind this isnt tested so probably wont work, but you get the idea):

function GameBase::SpawnMe(%theDB, %pos){
%myObject = new StaticShape() {
dataBlock = %theDB;
position = %pos;
};
}

then you would call that function like:
SpawnMe(myObject, %somePosition);
#2
12/18/2006 (4:15 am)
It's not a redundant question Rich... there's a lot of basic stuff you've gotta come to grips with, and it *can* be a bit overwhelming, especially in light of the volumes of infomation that is scattered all over the place...

i would advise you to buy the first Finney book, and take a week to go over it with these goals in mind...

1- understanding the basic structure of the engine and it's relation to the file structure... this is essential in understanding where to add script code and how to add objects at runtime...

2- understanding the client/server concept that is an integral part of the engine... ghost objects, control objects, datablocks, etc...

without an understanding of just these two things, you won't be able to go very far with TGE, and trying to pick it all up without the guidance of a clear, concise, and orderly approach will be quite a challenge...

good luck...

--Mike
#3
12/19/2006 (6:09 am)
Hi Folks,

sorry for the late answer, i was busy (with TGE, LOL!).

Thank you for all the answers, that helps a lot !
Ive learned a lot the last week, so this will definatly add to it.

DTS doesnt need relighting ?
YAY...that tidbit made my day !!!

Thank you ! And dont move out, i'll be back soon...LOL !


EDIT/PS.:
This is "local" code above, i think the best way to do this via server/client would be a clientside "creation function" and a serversided "commandToClient ('spawnWhateverWherever'), correct ?