Advertisement
Guest User

Conveyor.cs

a guest
Jan 2nd, 2022
1,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Conveyor : MonoBehaviour
  6. {
  7. public float speed;
  8. public float visualSpeedScalar;
  9.  
  10. private Vector3 direction;
  11. private float currentScroll;
  12.  
  13. private void Update()
  14. {
  15. currentScroll = currentScroll + Time.deltaTime*speed*visualSpeedScalar;
  16. GetComponent<Renderer>().material.mainTextureOffset = new Vector2(0, currentScroll);
  17. }
  18.  
  19. private void OnCollisionStay(Collision otherThing)
  20. {
  21. direction = transform.forward;
  22. direction = direction*speed;
  23.  
  24. otherThing.rigidbody.AddForce(direction, ForceMode.Acceleration);
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement