Castle Game Engine: Castle3D: Class T3DAlive

# Class T3DAlive
Description | Hierarchy | Fields | Methods | Properties
## Unit Castle3D ## Declaration `type T3DAlive = class(T3DOrient)` ## Description Alive, oriented 3D object. Basis for players, creatures and everything else that has some position, direction and that can be killed. Note that the `T3DAlive` doesn't remove dead objects, doesn't make any dead animations or such. `T3DAlive` class merely keeps track of Life, Dead and such properties, and allows you to call Hurt doing eventual knockback. If your own code doesn't call Hurt, or even doesn't look at Life value, then they have no implication for given 3D object, so it may be indestructible just like other 3D objects. ## Hierarchy TComponent T3D T3DList T3DCustomTransform T3DOrient T3DAlive ## Overview ### Fields
| `internal const DefaultKnockBackSpeed = 1.0;`
### Methods
| `procedure SetLife(const Value: Single); virtual;`
| `procedure CancelKnockback;`
| `constructor Create(AOwner: TComponent); override;`
| `function Dead: boolean;`
| `procedure Hurt(const LifeLoss: Single; const HurtDirection: TVector3Single; const AKnockbackDistance: Single; const Attacker: T3DAlive); virtual;`
| `procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;`
### Properties
| `property LastHurtDirection: TVector3Single read FLastHurtDirection;`
| `property LifeTime: Single read FLifeTime;`
| `property DieTime: Single read FDieTime;`
| `property Life: Single read FLife write SetLife;`
| `property MaxLife: Single read FMaxLife write FMaxLife;`
| `property KnockBackSpeed: Single read FKnockBackSpeed write FKnockBackSpeed default DefaultKnockBackSpeed;`
## Description ### Fields
| `internal const DefaultKnockBackSpeed = 1.0;`
### Methods
| `procedure SetLife(const Value: Single); virtual;`
| `procedure CancelKnockback;`
| `constructor Create(AOwner: TComponent); override;`
| `function Dead: boolean;`
Shortcut for checking Life <= 0.
| `procedure Hurt(const LifeLoss: Single; const HurtDirection: TVector3Single; const AKnockbackDistance: Single; const Attacker: T3DAlive); virtual;`
Hurt given creature, decreasing it's life by LifeLoss, setting last attack direction (used by knockback and some other effects), optionally doing a knockback. If all you want to do is to decrease Life, you can also just set Life property. Unless your code depends on LastHurtDirection being always updated (only TCreature in CastleCreatures unit depends on it now). HurtDirection should be a normalized vector indicating direction in which the attack came. AKnockbackDistance, if non-zero, indicates to push creature by given length in the direction given by HurtDirection. Ignored if HurtDirection is zero. Attacker is the other alive creature that caused this damage. It may be `Nil` if no other T3DAlive is directly responsible for this damage. This may be useful for various purposes, for example the victim may become aware of attacker presence when it's attacked.
| `procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;`
### Properties
| `property LastHurtDirection: TVector3Single read FLastHurtDirection;`
Direction from where the attack came. Zero if there was no specific direction of last attack, otherwise a normalized (length 1) vector.
| `property LifeTime: Single read FLifeTime;`
| `property DieTime: Single read FDieTime;`
Time of death, only valid if Dead, taken from LifeTime.
| `property Life: Single read FLife write SetLife;`
Current Life. We're dead when this is <= 0.
| `property MaxLife: Single read FMaxLife write FMaxLife;`
Maximum amount of life. Used as default value for Life when sensible. Can be also used for information (to display on player HUDs and such). It's not really a limit, that is you can set Life to something larger than `MaxLife` if you want. It's normal in some games, where you can get some "magic life boost" that makes your health temporarily larger than normal. Whether it's sensible in your game (and whether your HUD will display it sensibly) is up to you.
| `property KnockBackSpeed: Single read FKnockBackSpeed write FKnockBackSpeed default DefaultKnockBackSpeed;`
Scales how far the knockback effect pushes this creature/player.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:08