physics seemingly randomly turns on
by rennie moffat · in Torque Game Builder · 05/14/2010 (4:16 pm) · 16 replies
Hi there,
sometimes when a run level A, where level A has many objects, hundreds, it runs fine, just as planned, sometimes tho, say 1 in 10 (kind of high, too high actually), it is almost like physics suppress has been turned to false on many of the objects. Is this just due to behaviors and there, "instability"? or are there other possible reasons? Since my game requires no physics, is there a way in say the level.t2d to set a global to insure all objects have no physics applied?
As I side note I have put in an echo call to getPhysicsSuppress(), if false, I know this is the case, posting anyways tho as I do not know when it may happen again and am just looking for some advice.
Cheers
sometimes when a run level A, where level A has many objects, hundreds, it runs fine, just as planned, sometimes tho, say 1 in 10 (kind of high, too high actually), it is almost like physics suppress has been turned to false on many of the objects. Is this just due to behaviors and there, "instability"? or are there other possible reasons? Since my game requires no physics, is there a way in say the level.t2d to set a global to insure all objects have no physics applied?
As I side note I have put in an echo call to getPhysicsSuppress(), if false, I know this is the case, posting anyways tho as I do not know when it may happen again and am just looking for some advice.
Cheers
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
I have just began using setPhyicsSurpress and it works fine. Saves me a lot of time in terms of clicking each objects physics box. Anyhow, as I say, I do not want to reaise any alarms, as I do no know if it is physics yet, but I am experiencing something visually like that ocassionally. Every time so far when I reboot it it works fine.
05/14/2010 (4:25 pm)
True dat homie.I have just began using setPhyicsSurpress and it works fine. Saves me a lot of time in terms of clicking each objects physics box. Anyhow, as I say, I do not want to reaise any alarms, as I do no know if it is physics yet, but I am experiencing something visually like that ocassionally. Every time so far when I reboot it it works fine.
#3
05/14/2010 (4:39 pm)
Do all of your objects exist in the level designer?
#4
I am thinking perhaps this is a bad, or not optimal idea.
::::?
05/14/2010 (4:43 pm)
per level yes. I am thinking perhaps this is a bad, or not optimal idea.
::::?
#5
05/14/2010 (4:54 pm)
Unwieldy at least.
#6
I am sorry for asking but I have never really looked at this before. The one trick with me is that most of my objects own behaviors so if I am to add an object to scene at some point AFTER loadLevel, how do I ensure it owns a specific behavior?
05/14/2010 (5:34 pm)
I the future, for enemies, which I think in my case carry the bulk of programming power with onUpdate status', how would you better manage that? If my player hits a certain position/trigger etc, addToScene()?I am sorry for asking but I have never really looked at this before. The one trick with me is that most of my objects own behaviors so if I am to add an object to scene at some point AFTER loadLevel, how do I ensure it owns a specific behavior?
#7
Adding behaviors in script looks like this:
%this.addBehavior(GenericButtonBehavior.createInstance());
05/14/2010 (5:48 pm)
Your trigger would call a function that creates the enemies. If addToScene is an existing callback, don't use that. Create a custom function such as createEnemy()Adding behaviors in script looks like this:
%this.addBehavior(GenericButtonBehavior.createInstance());
#8
simple as that?
05/14/2010 (6:55 pm)
so would it just be like (forgive bad scripting but from the top of my head)...function createEnemy()
{
%this.enemy = new t2dStaticSprite{
image = thisImage;
class = enemyClass;
position = 30 40;
///etc etc etc....
}simple as that?
#9
Example:
Level is the class (aka namespace). %this refers to the Level in this case.
You should have a Level.cs file that contains all of the methods for the level. You should have an enemyClass.cs file that contains the enemy methods. Your enemyClass should have the onUpdate callback in it, which would look like this:
05/14/2010 (7:12 pm)
That's close, but %this should refer to something.Example:
function Level::createEnemy(%this)
{
%this.enemy = new t2dStaticSprite{
...Level is the class (aka namespace). %this refers to the Level in this case.
You should have a Level.cs file that contains all of the methods for the level. You should have an enemyClass.cs file that contains the enemy methods. Your enemyClass should have the onUpdate callback in it, which would look like this:
function enemyClass::onUpdate(%this)
{
//whatever
}
#10
As far as I know, any level.cs file.. well I never use them, I was thinking level.t2d.
Can you explain, help me clear this?
Also, you say I should have an enmeyClass.cs file which should contain all enemy methods. If this is the case, why? / Do I need a behavior still? I would think an enemyClass.cs file would contain/be the behavior in a way in that if I need enemy to "go here and do this" that it would be written in that enemyClass.cs file and thus no need for a behavior.
Can you help me clear up my thinking on this?
05/14/2010 (8:22 pm)
when you say a level.cs that should contain all methods for that level. What does this mean?As far as I know, any level.cs file.. well I never use them, I was thinking level.t2d.
Can you explain, help me clear this?
Also, you say I should have an enmeyClass.cs file which should contain all enemy methods. If this is the case, why? / Do I need a behavior still? I would think an enemyClass.cs file would contain/be the behavior in a way in that if I need enemy to "go here and do this" that it would be written in that enemyClass.cs file and thus no need for a behavior.
Can you help me clear up my thinking on this?
#11
This class per file approach follows the Fish Game tutorial. I suggest you go through that because it will show you basic techniques of class management. You will need to know this if you want to efficiently create enemies dynamically in script.
05/14/2010 (8:53 pm)
level.cs will contain all of the custom methods you create. Functionality such as creating enemies should go here. You could call it anything you want. "level.cs" just seems logical. You will still use behaviors by adding them in the script (see my reply at 8:48).This class per file approach follows the Fish Game tutorial. I suggest you go through that because it will show you basic techniques of class management. You will need to know this if you want to efficiently create enemies dynamically in script.
#12
I have noticed that in the level.t2d there is object, its image, class, behavior, size, position etc etc etc. I am mixing this up with your level.cs? I guess so since the enemy creation will need to be in here. So in your view, level.cs would contain level wide phenomenon? Such as spawning, maybe music controls, death, time?
Thanks tho, I will go through the fish tutorial today!
Cheers.
05/15/2010 (8:02 am)
I see thank you.I have noticed that in the level.t2d there is object, its image, class, behavior, size, position etc etc etc. I am mixing this up with your level.cs? I guess so since the enemy creation will need to be in here. So in your view, level.cs would contain level wide phenomenon? Such as spawning, maybe music controls, death, time?
Thanks tho, I will go through the fish tutorial today!
Cheers.
#13
05/15/2010 (8:11 am)
Exactly. But you should call it levelClass.cs to be in line with your naming convention.
#14
05/15/2010 (8:11 am)
hmm ok. thanks Kevin.
#15
%this.addBehavior(GenericButtonBehavior.createInstance());
createInstance(). This does what exactly, I ask because I could not find an immediate link. I can imagine it creates an instance where by the behavior is added, but when is that instance. I am sorry if it is very noobish.
EDIT::::
So an instance is an object in a class, say a bullet for a gun. so createInstance is just essentially creating that object with said behavior attached?
05/15/2010 (8:14 am)
ps%this.addBehavior(GenericButtonBehavior.createInstance());
createInstance(). This does what exactly, I ask because I could not find an immediate link. I can imagine it creates an instance where by the behavior is added, but when is that instance. I am sorry if it is very noobish.
EDIT::::
So an instance is an object in a class, say a bullet for a gun. so createInstance is just essentially creating that object with said behavior attached?
#16
Forgive me if I missed something. Thanks for all the previous help tho.
Cheers.
05/15/2010 (8:33 am)
Hi Kevin, I just went through the fishGameTutorial and I could not see how it tells you how to manage classes.It just seems to give you examples of a few behaviors. Forgive me if I missed something. Thanks for all the previous help tho.
Cheers.
Torque Owner Kevin James
I have no rational reason to force these defaults, but I want to avoid the type of mysterious behavior you are experiencing.