yes I think should attach script with counter Object.
Can you speak more clearly?
Can you speak more clearly?
The 3DRad community can be found at classdev.net.
I attached a script to EventonContact and used this script but don't work:
int Health = 100;
int Damage = 10;
void Main()
{
// int result = Health - Damage; //this will be 90
//result = Health; //this will be 90
if (Health == 0)// Will never == 0
{
iObjectHide (OBJ_44);
iObjectShow (OBJ_22);
}
}
int Health = 100;
int Damage = 10;
bTakeDamage = false;
void Main()
{
//You'll need to assign bTakeDamage to an event, eg: user has been shot etc.
if(bTakeDamage) //eg: Iam being hit, now i take away health
{
if(Health >= 10) // Only take health away when its >= 10
{
Health -= Damage;
}
bTakeDamage = false; //Reset this once damage has been applied
}
else if (Health == 0) //Your dead
{
iObjectHide (OBJ_44);
iObjectShow (OBJ_22);
}
}
int Health = 100;
int Damage = 10;
bool bTakeDamage = false;
void Main()
{
//You'll need to assign bTakeDamage to an event, eg: user has been shot etc.
if(bTakeDamage) //eg: Iam being hit, now i take away health
{
if(Health >= 10) // Only take health away when its >= 10
{
Health -= Damage;
}
bTakeDamage = false; //Reset this once damage has been applied
}
else if (Health == 0) //Your dead
{
iObjectHide (OBJ_44);
iObjectShow (OBJ_22);
}
}
Thanks Fourdee.Without seeing your project, i cant help you fix it.
But don't work this code.
I think it Will never ==0, Because no change (iObjectHide (OBJ_44), iObjectShow (OBJ_22)).
int TEXT_PRINT = OBJ_0;
int Health = 100;
int Damage = 10;
bool bTakeDamage = false;
//----------------------------------------------
void Main()
{
//This is the eventoninput force amount.
float ContactForce = IN_66;
if(ContactForce > 20000)
{
bTakeDamage = true; //Damage is now active
}
else if(bTakeDamage) //wait for contact force to go lower than 20,000 before we apply damage.
{
if(Health >= 10) // Only take health away when its >= 10
{
Health -= Damage;
}
bTakeDamage = false; //Reset this once damage has been applied
}
if(Health == 0) //Your dead
{
//This should be a switch (eg: done once).
//But, it will work as a loop for now.
iObjectHide(OBJ_44);
iObjectShow(OBJ_22);
}
//Print the results, so we can read the numbers :)
iPrint("Force: "+ContactForce,0,0,TEXT_PRINT);
iPrint("Health: "+Health,0,-5,TEXT_PRINT);
}