Health and amage in the racing mod
by Kirby Webber · in Torque Game Engine · 12/15/2002 (1:31 pm) · 4 replies
Having solved my previous camera/ render first person problems through the discovery of node manipulation ( =/ ) I have moved on to try an institute health and damage.
Having followed the tutorial to implement vehicle health and energy bars step by step, I realised (after the fact as usual) that my vehicle does not take damage!
Collisions register, and send you flying as they are supposed to at these speeds, however this does no physical damage to the player entity (vehicle) what-so-ever.
I have checked my data blocks, and made sure that maxDamage is assigned, as well as destroyed level, yet this seems to have no effect.
If someone could please point me to a tutorial, or explain the steps necessary to register damage to a vehicle in the racing mod, I'd greatly appreciate it.
Having followed the tutorial to implement vehicle health and energy bars step by step, I realised (after the fact as usual) that my vehicle does not take damage!
Collisions register, and send you flying as they are supposed to at these speeds, however this does no physical damage to the player entity (vehicle) what-so-ever.
I have checked my data blocks, and made sure that maxDamage is assigned, as well as destroyed level, yet this seems to have no effect.
If someone could please point me to a tutorial, or explain the steps necessary to register damage to a vehicle in the racing mod, I'd greatly appreciate it.
#2
I'll check into it further when I get home. Thanks for the help.
12/15/2002 (9:06 pm)
Nevermind... I found what I am missing in the tutorials.I'll check into it further when I get home. Thanks for the help.
#3
WhateverVechicle::onCollision
It's going to be a function. In here you should be able to WhateverVehicle::applyDamage(amount);
If that's not clear, let me know and I'll give you some solid examples.
12/16/2002 (9:57 pm)
You probably have something in script that is:WhateverVechicle::onCollision
It's going to be a function. In here you should be able to WhateverVehicle::applyDamage(amount);
If that's not clear, let me know and I'll give you some solid examples.
#4
I had to define all of the functions as they are defined in player.cc, i.e. onCollision, onAdd, onRemove, etc.
This got certain things to work properly (like collision... it was getting stuck) and that is great!
I added a damage function as per Badguys' tutorial. The health bar now reflects damage when you collide wth an object. The problem is, that death does not occur when health is depleted.
Reviewing the tutorial, I see that he calls of r an onDestroyed script, however, I can find no reference to this anywhere in the code! It's hard to script something when you have no idea what variables and parameters to pass in!
Incidentally, I ,modified the player::onDamage to affect my vehicle to get the damage working. As an experiment, I replaced it with Badguys' drone::onDamage function provided in the tutorial.
This led to some strange results:
First: On intial collision, all ENERGY depleted, and the debris activated as a result. Health still depleted as it is supposed to, but why would energy deplete as well?
Aslo: the player still does not die. Everything seems to indicate that damage is working, yet no death occurs.
Perhaps this could be due to the absence of an applyDamage() method as you suggest Jared. If that is the case, then yes I'd love to see an example function.
It helps to model after existing scripts and modify the portions I need, as I am still trying to wrap my widdle head around this engine. (Primarily experienced in C, so all this OO code is a little daunting. ;) )
Thanks again for your help guys... I appreciate your patience.
12/17/2002 (5:46 am)
Okay, here's where I'm at.I had to define all of the functions as they are defined in player.cc, i.e. onCollision, onAdd, onRemove, etc.
This got certain things to work properly (like collision... it was getting stuck) and that is great!
I added a damage function as per Badguys' tutorial. The health bar now reflects damage when you collide wth an object. The problem is, that death does not occur when health is depleted.
Reviewing the tutorial, I see that he calls of r an onDestroyed script, however, I can find no reference to this anywhere in the code! It's hard to script something when you have no idea what variables and parameters to pass in!
Incidentally, I ,modified the player::onDamage to affect my vehicle to get the damage working. As an experiment, I replaced it with Badguys' drone::onDamage function provided in the tutorial.
This led to some strange results:
First: On intial collision, all ENERGY depleted, and the debris activated as a result. Health still depleted as it is supposed to, but why would energy deplete as well?
Aslo: the player still does not die. Everything seems to indicate that damage is working, yet no death occurs.
Perhaps this could be due to the absence of an applyDamage() method as you suggest Jared. If that is the case, then yes I'd love to see an example function.
It helps to model after existing scripts and modify the portions I need, as I am still trying to wrap my widdle head around this engine. (Primarily experienced in C, so all this OO code is a little daunting. ;) )
Thanks again for your help guys... I appreciate your patience.
Torque Owner Badguy
simply find in the player.cs the logic applied to damage a player
it is the Same for Vehicle's (basically)
as all the neat little callbacks apply and you need only provide a damage(..) function for the VehicleData