예제 #1
0
 /// <summary>
 /// Make sure the player isn't holding an item when moving accross scenes.
 /// </summary>
 /// <param name="scene">The scene that was loaded.</param>
 /// <param name="mode">How the scene was loaded (i.e., additive vs. replace)</param>
 private void RemoveFromPlayer(Scene scene, LoadSceneMode mode)
 {
     if (GameManager.Player.CarriedItem == this)
     {
         OnPutDown();
         SavePosition pos = GetComponent <SavePosition>();
         pos.Retrieve();
     }
 }
예제 #2
0
        private void OnTriggerEnter2D(Collider2D collider)
        {
            SavePosition pos = collider.transform.root.GetComponentInChildren <SavePosition>();

            if (pos != null)
            {
                // Move the object back to its last saved position and
                pos.Retrieve();

                Rigidbody2D rb = collider.transform.root.GetComponentInChildren <Rigidbody2D>();
                if (rb != null)
                {
                    rb.velocity = Vector3.zero;
                }
            }
        }