Help Selecting Player Start point from Gui
by Diego Castaneda · in Torque 3D Professional · 07/02/2009 (2:16 pm) · 6 replies
Hello everybody, i'm having a hard time trying to make my player start the game where i want, i start the game with a gui in wich you put the position where you want your player to start, one textctrl for x position and another one for Y position and i save this values in variables in the same gui.
In order to change the position of the player, i call this variables in the .mis file in the position field of the spawn sphere marker like this:
position = "$posx $posy getterrainheight($posx, $posy);";
i'm just asking if anyone can help me with this problem, because in the console i got no errors but when i strat the mision the player falls from the terrain. And the point that i'm typing to start is the same one that was before.
Thanks a lot.
In order to change the position of the player, i call this variables in the .mis file in the position field of the spawn sphere marker like this:
position = "$posx $posy getterrainheight($posx, $posy);";
i'm just asking if anyone can help me with this problem, because in the console i got no errors but when i strat the mision the player falls from the terrain. And the point that i'm typing to start is the same one that was before.
Thanks a lot.
About the author
#2
07/02/2009 (3:18 pm)
Add some "z" to your getTerrainHeight() result. I'm guessing that your spawn point is being placed at the exact height of the terrain at that position -- half above and half below the terrain.
#3
07/03/2009 (12:41 pm)
thanks guys for the help but i cannot find in wich file the player is created and placed using the spawn sphere marker so i can change that function, i saw that in core/scripts/server/spawn.cs is a function called on
#4
thanks guys for the help, but i cannot find in wich file the player is created and placed using the spawn sphere marker, so i can change that function, i saw that in core/scripts/server/spawn.cs is a function called:
function GameConnection::spawnPlayer(%this, %spawnPoint)
so i dont know if is in here, and the ting that davide said about that my variables are in the client side and this file is in the server side, so i don´t know if i can use them in the SpawnPlayer function.
so maybe you can tell me if the player is placed in this function or in wich one, and if i can use the variables that i take from the gui in this function????
Thanks
07/03/2009 (12:48 pm)
sorry about the last post it was an internet failure :pthanks guys for the help, but i cannot find in wich file the player is created and placed using the spawn sphere marker, so i can change that function, i saw that in core/scripts/server/spawn.cs is a function called:
function GameConnection::spawnPlayer(%this, %spawnPoint)
so i dont know if is in here, and the ting that davide said about that my variables are in the client side and this file is in the server side, so i don´t know if i can use them in the SpawnPlayer function.
so maybe you can tell me if the player is placed in this function or in wich one, and if i can use the variables that i take from the gui in this function????
Thanks
#5
gameconnection::spawnPlayer(%this %spawnPoint)
but i can´t find where this function is called so i can control also wich spawnpoint is used to place the player. i alredy search in visual Studio in all the project and i can´t find it if anyone can tell me this i´ll apreciate it.
Thanks
07/03/2009 (1:26 pm)
hello everybody it seems that the player is placed using the functiongameconnection::spawnPlayer(%this %spawnPoint)
but i can´t find where this function is called so i can control also wich spawnpoint is used to place the player. i alredy search in visual Studio in all the project and i can´t find it if anyone can tell me this i´ll apreciate it.
Thanks
#6
hello.position = $posx SPC $posy SPC $altitude;
thanks for everything :)
07/03/2009 (4:12 pm)
ok i got it !!!!!!!! :) i named my spawn sphere marker as hello and from the loaddefault mission function in game/scripts/client/init.cs put the variables from the gui in the position field of the sphere markerhello.position = $posx SPC $posy SPC $altitude;
thanks for everything :)
Torque Owner Davide Archetti
Default Studio Name
Although, perhaps, there is a way to instruct .mis file to accept global variables as parameters, this is not how they where designed, they should contains only static data.
Then, torque script isn't PHP, it doesn't evaluate what is written inside quotes, you have to use the eval command.
What you can do is to spawn the player, using the standard code, and then change its position using your variable, something like:
%player should be a newly created player.
I cannot look at the code now, so I can't tell you where is the best place to insert that command.
Also, remember that your gui, and the variables you are using, are client side, so in reality, you cannot use the global variable $posx $posy, because they only exists client side, you have to send their value server side, for example using the connection parameters