I edited a script that would interact with my character so that it would reappear in another place (a respawn point), when it hit another item (specifically Smog).
function HitSmog ()
{
// If we've reached here, the player still has lives remaining, so respawn.
respawnPosition = Respawn.currentRespawn.transform.position;
Camera.main.transform.position = respawnPosition; // reset camera too
// Hide the player briefly to give the death sound time to finish...
SendMessage("HidePlayer");
// Relocate the player. We need to do this or the camera will keep trying to focus on the (invisible) player where he's standing on top of the FalloutDeath box collider.
transform.position = respawnPosition ;
yield WaitForSeconds(1.6); // give the sound time to complete.
// (NOTE: "HidePlayer" also disables the player controls.)
SendMessage("ShowPlayer"); // Show the player again, ready for...
// ... the respawn point to play it's particle effect
Respawn.currentRespawn.FireEffect ();
}
Then I created a script that would be put on the smog object to activate this script (which would be on my charactercontroller).
function OnTriggerEnter ()
{
var characterRespawn = GetComponent (CharacterRespawn);
characterRespawn.HitSmog ();
}
My problem is that the first script is causing the smog to move to the respawn point, not the charactercontroller. I this because I make the smog activate it? Or is it something else?
By the way, I took this script part from the 3D platform tutorial on unity3d.com, from the ThirdPersonStatus script (right near the end). THanks in advance.