From 2c4b6ec8baf224cf1b49aaa2a1337a9ad6c59af3 Mon Sep 17 00:00:00 2001 From: Ciakon Date: Wed, 3 Apr 2024 11:15:05 +0200 Subject: [PATCH] Ingredients go back to table after cooking --- Assets/Scenes/Noahs kælder.unity | 1 + Assets/Scripts/Ingredient.cs | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Assets/Scenes/Noahs kælder.unity b/Assets/Scenes/Noahs kælder.unity index 48dcb55..6f7ddbf 100644 --- a/Assets/Scenes/Noahs kælder.unity +++ b/Assets/Scenes/Noahs kælder.unity @@ -1327,6 +1327,7 @@ MonoBehaviour: IngredientIn: - {fileID: 460072661} - {fileID: 1680633067} + - {fileID: 449563471} NutritionalValue: 20 --- !u!212 &885031696 SpriteRenderer: diff --git a/Assets/Scripts/Ingredient.cs b/Assets/Scripts/Ingredient.cs index 21e4be0..a56af99 100644 --- a/Assets/Scripts/Ingredient.cs +++ b/Assets/Scripts/Ingredient.cs @@ -12,10 +12,10 @@ public class Ingredient : MonoBehaviour public int NutritionalValue; bool isMoving = false; //public GameObject table; - private Transform DefaultTransform; + private Vector3 DefaultPosition; void Start() { - DefaultTransform = transform; //TODO pointer error + DefaultPosition = transform.position; } // Update is called once per frame @@ -26,9 +26,6 @@ public class Ingredient : MonoBehaviour Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = new Vector3 (mousePosition.x, mousePosition.y, transform.position.z); } - - ResetPosition(); - } @@ -42,9 +39,6 @@ public class Ingredient : MonoBehaviour public void ResetPosition() { - transform.position = DefaultTransform.position; - Debug.Log(gameObject.name); - Debug.Log(transform.position); - Debug.Log(DefaultTransform.position); + transform.position = DefaultPosition; } }