Some TGB 1.5.1 bugs
by Aun Taraseina · in Torque Game Builder · 09/20/2007 (9:17 pm) · 16 replies
I started a 2D side scrolling game last week and I'm listing some bugs I found working with TGB 1.5.1 and 1.5.3 so other community members won't have to figure it out like I did.
1. Can't save file ( TGB 1.5.1 - 1.5.3 )
- It seems to be broken somewhere at
I just ignore why and change the method below
to
3. CloneWithBehavior won't clone the object's class and behavior field values ( when your not using the default values ) I did something like this to work around this issue
and create the object I want to copy the template to by using
4. There is a build-in EventManager class in TGB 1.5.1 but I found some issues when calling multiply events on mulitply objects and some of the events that were called will not be sent until some of the event before is done.
I instead create my own event manager class in script which was easy and haven't found a problem with it.
// %eventMan.registerEvent("eventName") ;
// %eventMan.postEvent("eventName");
// %eventMan.subscribe( %object , "eventName" ) ;
5. I can not get behaviors to work in TGB 1.5.3 when I try to iterate or call it's value TGB would crash. I didn't even debug why but instead change to TGB 1.5.1 and it seems to have no issues like TGB 1.5.3
Aun.
1. Can't save file ( TGB 1.5.1 - 1.5.3 )
- It seems to be broken somewhere at
bool ResManager::isValidWriteFileName (const char *fn)
I just ignore why and change the method below
void ResManager::setWriteablePath (const char *path)
{
dStrcpy (writeablePath, path);
}to
void ResManager::setWriteablePath (const char *path)
{
//dStrcpy (writeablePath, path);
}2. If you create your game project in the same folder as the Torque Game Builder execute Torque Game Builder won't find the managed datablocks ( TGB 1.5.3 ) 3. CloneWithBehavior won't clone the object's class and behavior field values ( when your not using the default values ) I did something like this to work around this issue
function copyAllBehavior( %obj , %template)
{
if( !isObject ( %template ) )
{
error ( "Template is not a Object " ) ;
return ;
}
%count = %template.getBehaviorCount() ;
for ( %i = 0 ; %i < %count ; %i++)
{
%behavior = %template.getBehaviorByIndex(%i) ;
%behaviorTemp = %behavior.template.getName() ;
%behaviorInst = %behaviorTemp.createInstance() ;
%obj.addBehavior( %behaviorInst ) ;
copyAllBehaviorField( %behaviorInst , %behavior ) ;
}
}
function copyAllBehaviorField( %behaviorRecv , %behaviorSender)
{
%count = %behaviorSender.getDynamicFieldCount();
for ( %i = 0 ; %i < %count ; %i++)
{
%fieldName = %behaviorSender.getDynamicField(%i) ;
%fieldValue = %behaviorSender.getFieldValue(%fieldName) ;
%behaviorRecv.setFieldValue( %fieldName , %fieldValue );
}
}and create the object I want to copy the template to by using
%player = new t2dAnimatedSprite () { class = "Player"; };
%player.init();
copyAllBehavior(%player , %temp);
%player.copy(%temp , true);
%player.enabled = true ;4. There is a build-in EventManager class in TGB 1.5.1 but I found some issues when calling multiply events on mulitply objects and some of the events that were called will not be sent until some of the event before is done.
I instead create my own event manager class in script which was easy and haven't found a problem with it.
// %eventMan.registerEvent("eventName") ;
// %eventMan.postEvent("eventName");
// %eventMan.subscribe( %object , "eventName" ) ;
function SEventManager::registerEvent( %this , %event )
{
if( Strpos( %this.registeredCallBack ,%event ) >= 0 )
return 0 ;
%this.registeredCallBack = %this.registeredCallBack $= "" ? %event : %this.registeredCallBack SPC %event ;
return 1 ;
}
function SEventManager::postEvent( %this , %event )
{
%index = %this.findEventIndex( %event ) ;
if(%index == -1 ) return ;
if(%this.registeredListener[%index] $= "" ) return ;
eval ( %this.registeredListener[%index] ) ;
}
function SEventManager::subscribe( %this , %object , %event )
{
%index = %this.findEventIndex( %event ) ;
%this.registeredListener[%index] = %this.registeredListener[%index] $= "" ? %object @".on" @ %event @ "();" : %this.registeredListener[%index] SPC %object @".on" @ %event @ "();" ;
}
function SEventManager::findEventIndex( %this , %event)
{
if( Strpos( %this.registeredCallBack ,%event ) < 0 )
return -1 ;
%count = getWordCount( %this.registeredCallBack ) ;
for (%i = 0 ; %i < %count ;%i++)
{
%word = getWord ( %this.registeredCallBack , %i ) ;
if ( %word $= %event)
return %i ;
}
return -1 ;
}5. I can not get behaviors to work in TGB 1.5.3 when I try to iterate or call it's value TGB would crash. I didn't even debug why but instead change to TGB 1.5.1 and it seems to have no issues like TGB 1.5.3
Aun.
About the author
COO for Kiragames, developer of Unblock Me. With over 60 million downloads and named #17 most download Application of all time. My work is to extend our IP to higher ground and find ways we can work with other awesome companies.
Recent Threads
#2
09/26/2007 (8:04 pm)
Currently 1.5.1 is the latest release of TGB...
#3
09/26/2007 (8:05 pm)
Good bug finds nonetheless.
#4
I have searched this lines but can't find the right file. Where is it?
Thanks
09/27/2007 (11:25 am)
void ResManager::setWriteablePath (const char *path)
{
dStrcpy (writeablePath, path);
}I have searched this lines but can't find the right file. Where is it?
Thanks
#6
09/27/2007 (11:35 am)
Ah. in which file?
#7
BTW It's in "resManager.cc".
Aun.
09/27/2007 (11:41 am)
If you are working on windows you could get VS 2005 express and use it to find functions.BTW It's in "resManager.cc".
Aun.
#9
Since I need a very accurate collision call back I created one more sceneObject with the same size but different collision mask and mounted to Object A so this new sceneObject can detect the other collision call back.
Aun.
10/04/2007 (2:22 am)
6. Multiply collisions on an object won't work ( or from the look of the source code they might have design it not to work, not sure if this can be considered as a bug or not ). So here's the deal when Object A is colliding with Object B then Object A also goes to collide with Object C either a call back for Object C or Object B won't get called.
Since I need a very accurate collision call back I created one more sceneObject with the same size but different collision mask and mounted to Object A so this new sceneObject can detect the other collision call back.
Aun.
#10
Could you clarify Topic 3 a little for me please? What do you use for %template when you call copyAllBehavior() ?
I'm trying to set up an object in the level builder and then just clone it with it's class, dynamic fields and behaviors.
10/20/2007 (12:25 pm)
Hi Aun, thanks for the great info!Could you clarify Topic 3 a little for me please? What do you use for %template when you call copyAllBehavior() ?
I'm trying to set up an object in the level builder and then just clone it with it's class, dynamic fields and behaviors.
#11
10/20/2007 (12:28 pm)
1.5.2 is in testing currently and will be released when it is ready.
#12
10/20/2007 (12:31 pm)
Thanks Kenneth. I didn't meant post #3. I meant the third bug report (Clone With Behavior) in Aun's original post.
#13
@Deozaan, Its just a sceneObject that uses the "templateBehavior" which is included with 1.5.1
Aun.
10/20/2007 (6:12 pm)
@ kenneth , Looking forward for it.@Deozaan, Its just a sceneObject that uses the "templateBehavior" which is included with 1.5.1
Aun.
#14
I really think that if you must have multiple collisions over lengthy periods of time, then you are doing something wrong.
For example: I am making a platformer game. When I first started, I had continuous ground collisions, so when I hit a wall, it basically ignored it. In this instance, I did not need continuous collisions, because I could just offset my position and disable gravity from pushing me downwards.
That was just a basic example, but in essence, you *should* not need multiple collisions as the likelihood of two objects just so happening to collide in the same frame is remote, or *should* be through design.
In my example, if the player hits the ground and at the same time hits an enemy or a bullet or something, then there might be a problem. However, because I have not got continuous collisions, in the next frame the collision with the other objects can be observed.
I really feel that in most (not all) circumstances that you wont need multiple collisions.
10/21/2007 (2:31 am)
Quote:6. Multiply collisions on an object won't work ( or from the look of the source code they might have design it not to work, not sure if this can be considered as a bug or not ).
I really think that if you must have multiple collisions over lengthy periods of time, then you are doing something wrong.
For example: I am making a platformer game. When I first started, I had continuous ground collisions, so when I hit a wall, it basically ignored it. In this instance, I did not need continuous collisions, because I could just offset my position and disable gravity from pushing me downwards.
That was just a basic example, but in essence, you *should* not need multiple collisions as the likelihood of two objects just so happening to collide in the same frame is remote, or *should* be through design.
In my example, if the player hits the ground and at the same time hits an enemy or a bullet or something, then there might be a problem. However, because I have not got continuous collisions, in the next frame the collision with the other objects can be observed.
I really feel that in most (not all) circumstances that you wont need multiple collisions.
#15
10/21/2007 (11:13 am)
Quote:Multiply collisions on an object won't workIt does work with me. And it work well enough for anything. In my platformer I don't prevent constant collision with the ground, and it's still working well with everything else.
#16
See whats going on there? It checks if there are any collisions, then it stores away the first one, sees if there are any with a collision time less than the first and chooses that one.
You cannot have multiple collisions in a single frame.
When another object collides with your character it will not be detected until the collision time is less than the collision time of the ground on your player. When I was using continous collisions, the ground collision time was usually < 0.001 seconds, so another object colliding with your character must be less than that time. Collisions with a negative collision time overlap, which is what I suspect happens for a brief period with your system in its current state.
Now, you may find that your game works, as I am sure it does (I've been watching it since the beginning, it looks really nice by the way), but continuous collisions are not a good thing in many situations.
10/21/2007 (2:20 pm)
I'm going to paste to you the comments within the collision system in TGB:Quote:
// Fetch Collision Count.
// Were there any collisions?
// Yes, so note first one.
// Do we need to check for quicker collisions?
// Yes, so find any quicker collisions.
// Quicker time?
// Yes, so note it.
// Flag Collision Detected.
// Set Collision Status.
// Process Collision Status.
See whats going on there? It checks if there are any collisions, then it stores away the first one, sees if there are any with a collision time less than the first and chooses that one.
You cannot have multiple collisions in a single frame.
When another object collides with your character it will not be detected until the collision time is less than the collision time of the ground on your player. When I was using continous collisions, the ground collision time was usually < 0.001 seconds, so another object colliding with your character must be less than that time. Collisions with a negative collision time overlap, which is what I suspect happens for a brief period with your system in its current state.
Now, you may find that your game works, as I am sure it does (I've been watching it since the beginning, it looks really nice by the way), but continuous collisions are not a good thing in many situations.
Torque Owner Isaac Barbosa
IQ Games
And I have found that 1.5.1 has lots of several bugs and I think I will go back to 1.1.3 :(
In my personal opinion I believe that it will be better to release a new version until get less or none bugs... but maybe this is not the vision of the project because is the community who found the bugs?