Moving Chimken

This commit is contained in:
2024-02-28 09:45:13 +01:00
parent 53ebf520ee
commit abeb9f28b9
4 changed files with 187 additions and 7 deletions

View File

@@ -5,8 +5,10 @@ using UnityEngine;
public class Ingredient : MonoBehaviour
{
// Start is called before the first frame update
//Vector3 mousePosition = Input.mousePosition;
public Vector3 transform;
Vector3 mousePosition;
public Transform transform;
bool isMoving = false;
//public GameObject table;
void Start()
{
@@ -15,6 +17,24 @@ public class Ingredient : MonoBehaviour
// Update is called once per frame
void Update()
{
//transform.position = Input
if (isMoving)
{
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector3 (mousePosition.x, mousePosition.y, transform.position.z);
//Debug.Log(table.Bounds.Contains(mousePosition));
}
}
void OnMouseUp()
{
if (isMoving)
isMoving = false;
else
isMoving = true;
}
}

18
Assets/Scripts/Table.cs Normal file
View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Table : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ff11aa56b668504fa25b3bbeafe65f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: