Some questions on script
by Patrick Jeeves · in Torque Game Engine · 09/05/2008 (10:07 am) · 5 replies
Hello,
i have some questions about some of the script commands and variables and such.
first off: in this resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7517
'getWorldBoxCenter()' is used to find the position of an object or something, but why not use 'getPosition()'? how are they different? i once had a 2D game engine where one command returned the center of an object and another returned the top left corner, is the difference between the two something of that nature?
-------
Second 'SpawnSphere' objects have the variables: 'Radius,' 'sphereWeight,' 'indoorWeight,' and 'outdoorWeight,' what do these do?
and speaking of things in markers.cs what exactly do 'WayPoints' do?
--------
finally in "The Game Programmer's Guide to Torque" a level loader is made so that different environments can be loaded in and out of missions, and i wanted to do something similar but also load interiors, so is there a way to switch out which light map a mission uses without changing any of the C++?
thank you for your time.
i have some questions about some of the script commands and variables and such.
first off: in this resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7517
'getWorldBoxCenter()' is used to find the position of an object or something, but why not use 'getPosition()'? how are they different? i once had a 2D game engine where one command returned the center of an object and another returned the top left corner, is the difference between the two something of that nature?
-------
Second 'SpawnSphere' objects have the variables: 'Radius,' 'sphereWeight,' 'indoorWeight,' and 'outdoorWeight,' what do these do?
and speaking of things in markers.cs what exactly do 'WayPoints' do?
--------
finally in "The Game Programmer's Guide to Torque" a level loader is made so that different environments can be loaded in and out of missions, and i wanted to do something similar but also load interiors, so is there a way to switch out which light map a mission uses without changing any of the C++?
thank you for your time.
#2
sphereWright, indoorWeight, and outdoorWeight do zilcho.
09/05/2008 (12:33 pm)
As far as i can tell from my reading of the TGE 1.4 source,sphereWright, indoorWeight, and outdoorWeight do zilcho.
#3
For a SpawnSphere, the radius is the radius of the sphere itself. This scales the SpawnSphere object model (which is only visible in the editor). I don't believe it has an actual purpose on it's own, but it would mainly be checked by spawn functions to contain spawning within the size of the sphere (so you do not have players spawning outside a building, etc...)
I don't believe any of the other fields for SpawnSpheres are used for anything besides script calls. I can't find anything in the starters about weights being used, but I imagine they were added to unbalance the randomity of choosing a spawn slightly, could be used to prevent heavy spawning in a crowded SpawnSphere. Working out a better algorithm to have a sphere with a higher weight more likely to be chosen would be pretty simple.
I've never used WayPoints, but it looks like an easy way to mark a specific spot with a named waypoint. Maybe for single player missions you want your player spawned in an exact location and have no need for a sphere? Use waypoints.
----
Never read "The Game Programmer's Guide to Torque", or tried to switch lightmaps dynamically, so no help here. Though I have not heard of a way to do this.
Edit: Just checked docs, and no the SpawnSphere fields are only made for use in script.
09/05/2008 (12:41 pm)
Yes the difference is a bit like that. GetWorldBoxCenter returns the centroid of the world box (the exact center) in world space. While getPosition returns the position of the object, at the bottom of it's Z axis, so for a player model this would return the location in between it's feet, while getWorldBoxCenter would return something around the stomach. Just try using each function in the console on a player object during any mission, copied from my console.log:==>echo(1784.getWorldBoxCenter()); 23.1063 -410.857 1.17005 ==>echo(1784.getPosition()); 23.1063 -410.857 0.0200536---
For a SpawnSphere, the radius is the radius of the sphere itself. This scales the SpawnSphere object model (which is only visible in the editor). I don't believe it has an actual purpose on it's own, but it would mainly be checked by spawn functions to contain spawning within the size of the sphere (so you do not have players spawning outside a building, etc...)
I don't believe any of the other fields for SpawnSpheres are used for anything besides script calls. I can't find anything in the starters about weights being used, but I imagine they were added to unbalance the randomity of choosing a spawn slightly, could be used to prevent heavy spawning in a crowded SpawnSphere. Working out a better algorithm to have a sphere with a higher weight more likely to be chosen would be pretty simple.
I've never used WayPoints, but it looks like an easy way to mark a specific spot with a named waypoint. Maybe for single player missions you want your player spawned in an exact location and have no need for a sphere? Use waypoints.
----
Never read "The Game Programmer's Guide to Torque", or tried to switch lightmaps dynamically, so no help here. Though I have not heard of a way to do this.
Edit: Just checked docs, and no the SpawnSphere fields are only made for use in script.
#4
Morrock:
i made this script:
then used the world editor creator made 3 different objects with the world editor creator and got this output:
why'd that happen?
-------
I looked in the source code too for the spawn spheres and the waypoints, but i thought i must be missing something as none of them seem to do anything without scripts to go with them. As for the radius of the spawn spheres i had to ask because i thought the size variable it inherited would accomplish the same thing.
-------
i had a feeling i would be the only person insane enough to want to do that.
09/05/2008 (1:09 pm)
Okay, thanks everyone!Morrock:
i made this script:
function TestShape::onAdd(%this,%obj) {
echo(%obj.getWorldBoxCenter());
echo(%obj.getPosition());
}then used the world editor creator made 3 different objects with the world editor creator and got this output:
0.00418748 0.00652818 0.0251389 0 0 0 0.00418748 0.00652818 0.0251389 0 0 0 0.00418748 0.00652818 0.0251389 0 0 0
why'd that happen?
-------
I looked in the source code too for the spawn spheres and the waypoints, but i thought i must be missing something as none of them seem to do anything without scripts to go with them. As for the radius of the spawn spheres i had to ask because i thought the size variable it inherited would accomplish the same thing.
-------
i had a feeling i would be the only person insane enough to want to do that.
#5
09/05/2008 (1:16 pm)
Probably the script-OnAdd gets called before the world editor has placed them at the drop position. So they are still at 0,0,0.
Associate James Ford
Sickhead Games