Quantcast
Channel: Answers for "how to save last position for the player before he die"
Viewing all articles
Browse latest Browse all 4

Answer by andrew lukasik

$
0
0
Add to your player script like this one for example: using UnityEngine; using System.Collections; public class RespawnMe : MonoBehaviour { private static Vector3 respawnPosition = Vector3.zero; private string levelWeAreIn = ""; void Start () { if (levelWeAreIn!=Application.loadedLevelName) { levelWeAreIn = Application.loadedLevelName; respawnPosition = Vector3.zero; } if (respawnPosition==Vector3.zero) respawnPosition = transform.position; else transform.position = respawnPosition; } void OnDestroy () { respawnPosition = transform.position; } }

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>