Need help on creating game object using script
by Simon Shum · in Technical Issues · 03/07/2007 (2:06 am) · 4 replies
Dear all,
I try to create my map using script (putting in game object through script, not by using the internal editor). I first setup an array, then define the game object, finally put into the map like this:
Exec("./map/initMapLd.cs"); //for setting up the array
...
function InsertBattleLand(%locX, %locY, %boxType , %level)
{
switch(%boxType)
{
case 1:
%land = new StaticShape() {
datablock = Grass;
rotation = "0 0 1 0"; // initialize the values
....
}
%land.setTransform( " " @ 98-%locX*2 @ " " @ 0+%locY*2 @" " @ 70+(%level-1)*1 @ " 0 0 0 0");
MissionCleanup.add(%land);
// Player setup
return %land;
}
The script works and the map is built (game object filling up the space). However, the video memory will fill up very quickly because each game object is treated as a new object (identical texture map will be used many times).
How can i fix that problem? Is there anyway around using this method? I'm a very inexperienced programmer so please bear with me with this question. Any suggestion is welcome. Thanks a lot!!
SS.
I try to create my map using script (putting in game object through script, not by using the internal editor). I first setup an array, then define the game object, finally put into the map like this:
Exec("./map/initMapLd.cs"); //for setting up the array
...
function InsertBattleLand(%locX, %locY, %boxType , %level)
{
switch(%boxType)
{
case 1:
%land = new StaticShape() {
datablock = Grass;
rotation = "0 0 1 0"; // initialize the values
....
}
%land.setTransform( " " @ 98-%locX*2 @ " " @ 0+%locY*2 @" " @ 70+(%level-1)*1 @ " 0 0 0 0");
MissionCleanup.add(%land);
// Player setup
return %land;
}
The script works and the map is built (game object filling up the space). However, the video memory will fill up very quickly because each game object is treated as a new object (identical texture map will be used many times).
How can i fix that problem? Is there anyway around using this method? I'm a very inexperienced programmer so please bear with me with this question. Any suggestion is welcome. Thanks a lot!!
SS.
#3
03/07/2007 (5:52 am)
@Aun: Yes, in same special situations it makes sense to use auto-generated world objects. I used this a while ago when I imported maze-style worlds into Torque and created the objects code-wise.
#4
any suggestion on how to place object by script using method similar to replicator? such that all the objects will share one texture map?
thanks!!
03/07/2007 (9:21 pm)
Thanks for the advice but i don't want a random distribution of the game objects. we have setup a specific way to place all the objects in order. any suggestion on how to place object by script using method similar to replicator? such that all the objects will share one texture map?
thanks!!

Torque Owner Martin Schultz