- Home /
C# Respawn Help
I was wondering if anyone could help me with figuring out how to create a c# respawn script. You see I am using the Free Fantasy AI package available on the unity asset store, there isn't anything in the script to respawn player if he/she dies.
My problem is that I have only being able to create a respawn script in java script and have no clue how you would go around creation one in C#, if anyone could help me in any way that would be great.
Just in case anyone is wondering, this is the respawn script I created in java script... var startPosition : Transform;
function OnTriggerEnter(theCollider : Collider)
{
theCollider.transform.position = startPosition.position;
}
Go dtí an chéad uair eile, slán leat
I could convert your script to C# but all your code does, is moving (the player I guess) from its current position to the start position.
I'm not sure that's really "respwaning".
But if that's what you are looking for, I can give you the C# version of your code.
Yea thats pretty much all I'm doing really, I mean I know its not the right way to respawn the player, but it works for now. Thanks for the help.
Yes but, if you have health or any other vars, you should just destroy and Instatiate. Unless you have many players being respanwed.
Answer by landon912 · Mar 17, 2013 at 09:57 PM
Transform startPosition //Creates a var of type Transform named startPosition
void OnTriggerEnter(Collider theCollider){
theCollider.transform.position = startposition.position;
}
Thanks for writing the script in C# for me. If I was to try to get a respawn script to work correctly, what would I have to do? I mean I now I would have to destroy the player (game object) and reset the health and another variables but what else would I have to do?
All you would have to do is destroy the player than recreat it in a designated spot. All vars will be reset since the scripts are not the same instance.
If this sovled the problem click the check next to the answer. :D
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Respawning without creating Clones 2 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Help With Simple Jump Script 1 Answer