using System.Collections.Generic; using System.Diagnostics; using NUnit.Framework; using UnityEngine; public class Conveior : MonoBehaviour { [SerializeField] float speed, conveyorSpeed; //una pentru obiect si alta pentru conveior [SerializeField] Vector3 direction; // directia in care deplaseaza obiectul [SerializeField] private List objectsOnBelt = new List(); //lista cu obiectele care se afla pe conveior private Material material; //materialul conveiorului, cel care se va invarti void Start() { material = GetComponent().material; //Renderer.me UnityEngine.Debug.Log(material.GetTexturePropertyNames()[0]); foreach(var mat in material.GetTexturePropertyNames()) { UnityEngine.Debug.Log(mat); } } void Update() { GetComponent().material.mainTextureOffset += new Vector2(0,1) * conveyorSpeed * Time.deltaTime; } private void FixedUpdate() { for (int i=0;i<=objectsOnBelt.Count - 1;i++) { //objectsOnBelt[i].GetComponent().AddForce(speed * direction); Vector3 move = objectsOnBelt[i].transform.position + direction * speed * Time.deltaTime; objectsOnBelt[i].GetComponent().MovePosition(move); } } private void OnCollisionEnter(Collision collision) { objectsOnBelt.Add(collision.gameObject); UnityEngine.Debug.Log("Salt"); } private void OnCollisionExit(Collision collision) { objectsOnBelt.Remove(collision.gameObject); UnityEngine.Debug.Log("Salt"); } }