Game Development Community

fish game behavior mine and bubble problem

by hamed · in Game Design and Creative Issues · 02/14/2012 (1:49 am) · 3 replies

hi
im studying fish gane behavior tut, and everything is ok but the buble and the mine doesnt respawn and even doesnt move , this is my console error log to me
E:/My Fantastic Game/Test/MyGame666/game/behaviors/modifyHealth.cs Line: 48 - parse error
>>> Advanced script error report. Line 48.
>>> Some error context, with ## on sides of error halt:
// lets update the health of the object we are colliding with

if(%dstObj.hasHealth)

{

%dstObj.updateHealth(%this.healthModifier);

%this.respawn();

}

}



function fishModifyHealthBehavior::onWorldLimitt2dSceneObject::onWorldLimit(%this,

## ## %limitMode, %limit)(%this, %mode, %limit)

{

switch$(%limit)

{ echo("lol")

case "bottom":

%this.respawn();

}

}



function fishModifyHealthBehavior::respawn(%this)

{

%this.owner.setPositionY(%this.startPositionY);
>>> Error report complete.
and this is my modifyhealth behavior
if(!isObject(fishModifyHealthBehavior))
{
%template = new BehaviorTemplate(fishModifyHealthBehavior);
%template.friendlyName = "Fish Tutorial Modify Health";
%template.behaviorType = "Gameplay";
%template.description = "Modify health control for our Fish Tutorial";
%template.addBehaviorField(healthModifier,
"Value in which to modify the health by", integer, 2);
%template.addBehaviorField(minSpeed, "The min random speed to float down", float, 5);
%template.addBehaviorField(maxSpeed, "The max random speed to float down", float, 15);
}

function fishModifyHealthBehavior::onBehaviorAdd(%this)
{
// enable collision for sending and then enable the callback
%this.owner.collisionActiveSend = true;
%this.owner.collisionActiveReceive = false;
%this.owner.collisionCallback = true;

// disable physics
%this.owner.collisionPhysicsSend = false;
%this.owner.collisionPhysicsReceive = false;

// set the world limit
%this.owner.worldLimitMin = "-50 -45";
%this.owner.worldLimitMax = "50 45";
%this.owner.worldLimitMode = "NULL";
%this.owner.worldLimitCallback = true;
}

function fishModifyHealthBehavior::onAddToScene(%this, %scenegraph)
{
%this.startPositionY = %this.owner.getPositionY();
%this.respawn();
}

function fishModifyHealthBehavior::onCollision(%this, %dstObj, %srcRef, %dstRef, %time,
%normal, %contacts, %points)
{
// lets update the health of the object we are colliding with
if(%dstObj.hasHealth)
{
%dstObj.updateHealth(%this.healthModifier);
%this.respawn();
}
}

function fishModifyHealthBehavior::onWorldLimitt2dSceneObject::onWorldLimit(%this,
%limitMode, %limit)(%this, %mode, %limit)
{
switch$(%limit)
{ echo("lol")
case "bottom":
%this.respawn();
}
}

function fishModifyHealthBehavior::respawn(%this)
{
%this.owner.setPositionY(%this.startPositionY);
%this.owner.setLinearVelocityY(getRandom(%this.minSpeed, %this.maxSpeed));
}
would anybody tell me why my mine and bubble dont move ? why they are so sad that hang in a corner of screen?

About the author

the great costly games, but the only purpose is killing, and the only amuse but why we just should kill to be satisfied,why the games should not change ? great drama in the games ? maybe today , is the time to change from bullets to flowers


#1
02/14/2012 (9:51 am)
hi hamed,

first off, try to paste smaller segments of code because it is easier to read it....and use the code], [/code] brackets so its more apparent.

regarding your case, I presume the code isnt the full segment, but if it is, the very first if clause, has one bracket too many...check those brackets thoroughly, they are usually the culprit, especially in tutorials where you copy paste most of thecode

if(%dstObj.hasHealth)

{

%dstObj.updateHealth(%this.healthModifier);

%this.respawn();

}

}   <----- ??
#2
02/14/2012 (2:41 pm)
function fishModifyHealthBehavior::onWorldLimitt2dSceneObject::onWorldLimit(%this,
%limitMode, %limit)(%this, %mode, %limit)

See anything wrong with that? Looking for two sets of parameters for the same function - (%this,
%limitMode, %limit)(%this, %mode, %limit) - is bound to cause problems.

And, like the previous poster noted - watch your braces.
#3
02/14/2012 (7:04 pm)
thanks, my problem get solved i replaced the code
function fishModifyHealthBehavior::onWorldLimitt2dSceneObject::onWorldLimit(%this,
%limitMode, %limit)(%this, %mode, %limit)
{
switch$(%limit)
{ 
case "bottom":
%this.respawn();
}
}
with the code
function fishModifyHealthBehavior::onWorldLimit(%this,  %limit)
{   
   if(%limit = 42)
   
   %this.respawn();
    
   
}
indeed the most important change that i did was deleting the onWorldLimitt2dSceneObject from the behavior
thabks again i nearly was disappointed to fixing that