SetHidden of the Player/AIPlayer crash
by Samme Ng · in Torque Game Engine · 12/18/2003 (1:09 am) · 19 replies
Hi all,
I have tried to type the setHidden to the Player or AIPlayer object in the console window, but the game crash!
It is crashed in the following:
void Container::findObjects(const Box3F& box, U32 mask, FindCallback callback, void *key)
{
.......
SceneObjectRef* chain = mBinArray[base + insertX].nextInBin; // <<<<<< Crash in this line
......
}
Do anyone tried?
In fact, due to some reason, I would like to group all NPC, Players under a SimGroup and to show/hide them all from time to time, do anyone have a good suggestion to make it work?
Thanks.
Samme
I have tried to type the setHidden to the Player or AIPlayer object in the console window, but the game crash!
It is crashed in the following:
void Container::findObjects(const Box3F& box, U32 mask, FindCallback callback, void *key)
{
.......
SceneObjectRef* chain = mBinArray[base + insertX].nextInBin; // <<<<<< Crash in this line
......
}
Do anyone tried?
In fact, due to some reason, I would like to group all NPC, Players under a SimGroup and to show/hide them all from time to time, do anyone have a good suggestion to make it work?
Thanks.
Samme
#2
but i will not use the native network and client/server system to keep track of online players.
in my current planning, one our game server (not TGE's server) tell me to add a online player at certain position, I would like to add a "Player" object to a SimGroup under RootSimGroup.
In our game design, we may use a special area of terrain, which there may be players there. So I would like to hidden them all and add another group of object to the area. That's the reason to hide the objects.
I am not sure if I need to use Player class for all others online player, as I would like to use its functions to move the player easily.
Any suggestion? ^^
Thanks!!!
12/18/2003 (6:19 pm)
Basically, I would like to use TGE for a MMORPG.but i will not use the native network and client/server system to keep track of online players.
in my current planning, one our game server (not TGE's server) tell me to add a online player at certain position, I would like to add a "Player" object to a SimGroup under RootSimGroup.
In our game design, we may use a special area of terrain, which there may be players there. So I would like to hidden them all and add another group of object to the area. That's the reason to hide the objects.
I am not sure if I need to use Player class for all others online player, as I would like to use its functions to move the player easily.
Any suggestion? ^^
Thanks!!!
#3
I was just doing the same sort of thing for my AI system. and I keep having the same problem.
I tracked things down a bit more in debug, and it seemed that the AI object was not a member of a container, and the container in question was NULL. which would make sense that it would crash inside it's function.
I'm not sure why it's null though. I was thinking perhaps I'm trying to hide something that is beyond the far plane so it's not being updated or something. But that's just crazy guessing.
Anyone else have a thought on this problem? or run into it yourself?
here's the relevant code:
so if the ai is a certain distance away from the player it will hide itself and once you are close enough it will unhide itself.
04/01/2005 (2:10 pm)
Ah hah, someone else with the same problem...but over a year ago with no solution posted.I was just doing the same sort of thing for my AI system. and I keep having the same problem.
I tracked things down a bit more in debug, and it seemed that the AI object was not a member of a container, and the container in question was NULL. which would make sense that it would crash inside it's function.
I'm not sure why it's null though. I was thinking perhaps I'm trying to hide something that is beyond the far plane so it's not being updated or something. But that's just crazy guessing.
Anyone else have a thought on this problem? or run into it yourself?
here's the relevant code:
if(%this.ai_distanceToClosestPC < $AI::StopThinkAndHideDist)
{
//%this.setHidden(false); //causes crash must figure out:(
blah blah blah ai thinking stuff
}
else
{
//%this.setHidden(true); //causes crash :(
}so if the ai is a certain distance away from the player it will hide itself and once you are close enough it will unhide itself.
#4
I could put checks for mContainer in the player/aiplayer class, but I don't know seems like something I shouldn't have to do, no?
04/01/2005 (2:12 pm)
I'm doing this on the AIPlayer class object that was part of TGE 1.3I could put checks for mContainer in the player/aiplayer class, but I don't know seems like something I shouldn't have to do, no?
#5
Most likely you want "setCloaked()".
04/01/2005 (4:01 pm)
You cannot use "setHidden()" on a player object. Set hidden actually deletes the object from the scene. And since your control object is being deleted you crash.Most likely you want "setCloaked()".
#6
so removing it from the scene but still processing it is what I'd like to do.
doing this to speed up processing when the ai is relatively far away.
when you are cloaked, it looked to me like you were still rendering+animating the character.
maybe there is another existing way to do what I want?
so right now I have the AI think less and less the further it is away from the nearest human player. and once you are at a certain distance away I can basically turn the ai off until you come closer.
This will speed up network traffic since the 'hidden' ai will not need to send info to the client. And since I'm making a single player game, hopefully it'll speed everything up and let me have more active AI on a map.
I could do other tricks, like drop an ai spawn marker when the ai goes out of scope, and whenever a spawn marker comes in scope, respawn the ai...but this seems like more work that necessary for now.
thanks for the help.
04/01/2005 (4:43 pm)
What I want to happen is for the ai to be removed from the client's scene while still getting updated on the server. so removing it from the scene but still processing it is what I'd like to do.
doing this to speed up processing when the ai is relatively far away.
when you are cloaked, it looked to me like you were still rendering+animating the character.
maybe there is another existing way to do what I want?
so right now I have the AI think less and less the further it is away from the nearest human player. and once you are at a certain distance away I can basically turn the ai off until you come closer.
This will speed up network traffic since the 'hidden' ai will not need to send info to the client. And since I'm making a single player game, hopefully it'll speed everything up and let me have more active AI on a map.
I could do other tricks, like drop an ai spawn marker when the ai goes out of scope, and whenever a spawn marker comes in scope, respawn the ai...but this seems like more work that necessary for now.
thanks for the help.
#7
These two statements taken separately are true, but they don't make sense together. You don't really have "network traffic" in a single player per se, and since the server and the client are co-located in the same executable, it actually won't be speeding things up much, since the server side is still processing everything. Yes, the client won't be trying to render/process if you have scripts for that particular object client side, but that's really the only savings you will get in a single player game.
04/01/2005 (5:00 pm)
@Clint: This is what scoping does--removes objects that are not within a particular observation rule which is defined by the object class'es "onCameraScopeQuery()". TAP takes care of deciding (based on this function, and other settings) if an object should continue to update a particular client or not. The object will still always stay on the server.Quote:This will speed up network traffic since the 'hidden' ai will not need to send info to the client. And since I'm making a single player game, hopefully it'll speed everything up and let me have more active AI on a map.
These two statements taken separately are true, but they don't make sense together. You don't really have "network traffic" in a single player per se, and since the server and the client are co-located in the same executable, it actually won't be speeding things up much, since the server side is still processing everything. Yes, the client won't be trying to render/process if you have scripts for that particular object client side, but that's really the only savings you will get in a single player game.
#8
unfortunately it's not immediately obvious what I need to do :) I'll look through oncameraScopeQuery and see what I can figure out.
I don't know what TAP is.
I know it isn't truely going over a network, but the pack/unpack update processing still occurs. In the tests I've done, when sethidden did work without crashing (it did work sometimes go figure but not reliably) it seemed to speed things up greatly when I had about...14 ai spread throughout a large map. looking at the network traffic meter I could see the bits sent were about half what they were otherwise...I haphazardly assumed that was the cause for the speedup.
I bashfully admit I didn't even verify that pack/unpack updates don't occur when an object is hidden...I just assumed that would probalby be the case.
it could have simply been not rendering all the skinned characters that was speeding things up though instead of the updates...
04/01/2005 (5:12 pm)
Stephen, thanks for the info..unfortunately it's not immediately obvious what I need to do :) I'll look through oncameraScopeQuery and see what I can figure out.
I don't know what TAP is.
Quote:These two statements taken separately are true, but they don't make sense together. You don't really have "network traffic" in a single player per se, and since the server and the client are co-located in the same executable, it actually won't be speeding things up much, since the server side is still processing everything. Yes, the client won't be trying to render/process if you have scripts for that particular object client side, but that's really the only savings you will get in a single player game.
I know it isn't truely going over a network, but the pack/unpack update processing still occurs. In the tests I've done, when sethidden did work without crashing (it did work sometimes go figure but not reliably) it seemed to speed things up greatly when I had about...14 ai spread throughout a large map. looking at the network traffic meter I could see the bits sent were about half what they were otherwise...I haphazardly assumed that was the cause for the speedup.
I bashfully admit I didn't even verify that pack/unpack updates don't occur when an object is hidden...I just assumed that would probalby be the case.
it could have simply been not rendering all the skinned characters that was speeding things up though instead of the updates...
#9
either modify sethidden for aiplayer, or add a new function
that flags the AI object as sleeping/outofscope/whatever word you like.
then I can toggle that to get what I want.
04/01/2005 (5:23 pm)
Ok so looking over the network docs and the function a bit, it looks like what I need to do is either modify sethidden for aiplayer, or add a new function
that flags the AI object as sleeping/outofscope/whatever word you like.
then I can toggle that to get what I want.
#10
so what I could do is add a generic out of scope distance.
then when some controlling object querries an object if it's in scope, I could check the "out of scope distance" vs the distance to the controlling object.
great. thanks for pointing me in the right direction .
I'm surprised this isn't in there already?
(It still isn't right that sethidden should crash the engine though :) )
04/01/2005 (5:27 pm)
Reading over it a bit more...ok this makes sense.so what I could do is add a generic out of scope distance.
then when some controlling object querries an object if it's in scope, I could check the "out of scope distance" vs the distance to the controlling object.
great. thanks for pointing me in the right direction .
I'm surprised this isn't in there already?
(It still isn't right that sethidden should crash the engine though :) )
#11
02/09/2007 (3:16 pm)
But you have still not answered why the game crashes when you try to use Sethide on an AI player. I am running into the same problem of needing to hide an Ai but the engine crashes every time I try. Can anyone answer why the engine crashes when you try to hide an AI player.
#12
02/09/2007 (11:04 pm)
I am no scripter, Tho would it not be feasable to "destroy object class: NPC" then have it respawn when the server was ready for it to? On some sort of timer... To cycle between Destroyed, then time to live, and poof they are gone again... Then some kind of loop would take place to do it all over again...
#13
02/24/2007 (5:55 pm)
I agree. If you are going to make AI "think" less or not at all when a player is far enough away, then you would be far better off just deleting them and respawning when needed. Deleting the AI players will remove all the load they put on the engine, not just some of it.Quote:
Can anyone answer why the engine crashes when you try to hide an AI player.
Quote:
You cannot use "setHidden()" on a player object. Set hidden actually deletes the object from the scene. And since your control object is being deleted you crash.
Most likely you want "setCloaked()".
#14
09/03/2007 (7:05 am)
In my game i have some NPCs that have important variables on them, because of this, i dont want to delete them and respaw when i need them again, i really need to hide and unhide in other part of the game. I dont undestant what the object control has to do with it, since it is not my player, it is a simple NPC (AiPlayer).
#15
11/20/2007 (8:13 pm)
Same here. I don't want them deleted. It MUST be hidden. And although they are implemented from Player class, they're not control objects either.
#16
11/22/2007 (12:30 am)
Oh well, no choice but to use setCloaked()
#17
12/31/2007 (10:54 am)
Torque crashes due to collision checks that players uses. I remember another post about this that had a fix for it.
#18
01/02/2008 (7:40 am)
I seem to remember that as well, Ramen-sama, but my mad search skizzilz are on vacation this morning it seems.
#19
http://www.garagegames.com/mg/forums/result.thread.php?qt=46932
Hope this helps anyone struggling to find a solution to this.
09/20/2008 (11:45 pm)
OK i was having a hard time wondering why my AIPlayer objects are crashing whenever I setHidden(true) on them and chanced upon this thread. Also I have found the other thread Ramen-sama is talking about which fixes the problem on collision issues here:http://www.garagegames.com/mg/forums/result.thread.php?qt=46932
Hope this helps anyone struggling to find a solution to this.
Torque Owner Westy
Are you looking to make players invisible or remove them all together?