Version: 2017.3
public static float Repeat (float t, float length);

Descripción

Loops el valor t, de modo que nunca es mayor que la longitud y nunca menor que 0.

Esto es similar al operador del módulo, pero funciona con números de punto flotante. Por ejemplo, usando 3.0 para t y 2.5 para length, el resultado sería 0.5. Con t = 5 y longitud = 2,5, el resultado sería 0,0. Tenga en cuenta, sin embargo, que el comportamiento no está definido para números negativos como lo es para el operador de módulo.

In the example below the value of time is restricted between 0.0 and just under 3.0. This is then used to keep the x position in this range.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.position = new Vector3(Mathf.Repeat(Time.time, 3), transform.position.y, transform.position.z); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961