Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Mathf.PingPong

マニュアルに切り替える
public static float PingPong(float t, float length);

パラメーター

説明

値 t を行き来させます。 t は length より大きくなることも 0 より小さくなることもありません。

返される値は 0 と length の間を行ったり来たり移動します。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.position = new Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z); } }