Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Conveyor : MonoBehaviour
- {
- public float speed;
- public float visualSpeedScalar;
- private Vector3 direction;
- private float currentScroll;
- private void Update()
- {
- currentScroll = currentScroll + Time.deltaTime*speed*visualSpeedScalar;
- GetComponent<Renderer>().material.mainTextureOffset = new Vector2(0, currentScroll);
- }
- private void OnCollisionStay(Collision otherThing)
- {
- direction = transform.forward;
- direction = direction*speed;
- otherThing.rigidbody.AddForce(direction, ForceMode.Acceleration);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement