using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ConveyorMaterialMotion : MonoBehaviour
{
public float speed = 1.0f;//定义了一个公共变量speed,用于设置传送带的移动速度,默认值为1.0单位每秒。
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float Transition = Time.time * speed;//计算了当前时间(Time.time)乘以速度变量,
Transition = 0.12f * -Transition;//进行倍率换算,
GetComponent<Renderer>().material.mainTextureOffset = new Vector2 (0,Transition); // 获取当前游戏物体的Renderer组件并获取其材质,
// 然后设置主纹理的偏移量为水平方向不变(0),垂直方向根据Transition值动态变化。
}
}
04-05
04-09