Game Development Community

Applying Damage Preventing Player Respawn

by Djekko Spurgin · in Torque 3D Beginner · 04/21/2016 (3:10 am) · 3 replies

I have Problem with re-spawning the player after death. If the player killed via fall damage or gun damage then they die and you can re-spawn straight away. I want it so that when the player enters the water they die.

I have applied this function to my player.cs

function Player::onEnterLiquid(%this,%obj){
%obj.applyDamage(100);
}

This works in the sense that it kills the player. But then it wont re-spawn.

I've looked around some people have suggested changing the liquid type to lava instead but I need it to stay as water. It is a multiplayer game and one character can swim and the other can't. Also i want to be able to use a similar way to apply damage when colliding with certain objects.

I'm wondering if there is a specific deceleration for telling the game the player is dead or something.

#1
04/21/2016 (5:51 am)
Instead, modify PlayerData::onEnterLiquid()
function PlayerData::onEnterLiquid(%this, %obj, %coverage, %type)
{
   %obj.damage(100);
}

That should run you through PlayerData::damage(), which should handle telling the client to respawn when it passes through the "Dead" check.
#2
04/21/2016 (8:06 am)
thanks Richard but when i tried your solution I had no luck there was no damage being applied to the player. I then thought to use apply damage instead see if that worked so the code looked like this

function PlayerData::onEnterLiquid(%this, %obj, %coverage, %type)  
{  
   %obj.applyDamage(100);  
}

but this gave me my original result the player dies and can't re-spawn
#3
04/21/2016 (8:46 am)
I seemed to have found a solution but im not sure if its the best.

This is the code i ended up using

function Player::onEnterLiquid(%this,%obj){
%obj.kill();
}


I can now respawn after dying now aswell