using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class API10Mathf : MonoBehaviour {
public Transform cube;
// Use this for initialization
void Start() {
Debug.Log(Mathf.Rad2Deg);
//角度變度數
Debug.Log(Mathf.Deg2Rad);
//度數變角度
Debug.Log(Mathf.Infinity);
//正無窮
Debug.Log(Mathf.Epsilon);
//極小值
Debug.Log(Mathf.PI);
Debug.Log(Mathf.NegativeInfinity);
//負無窮
Debug.Log(Mathf.Ceil(10.2f));
//向上取整
Debug.Log(Mathf.Floor(10.2f));
//向下取整
Debug.Log(Mathf.Pow(2,5));
//2的5次方
Debug.Log(Mathf.Sqrt(5));
//5的平方根
Debug.Log(Mathf.Max(5,6));
Debug.Log(Mathf.Min(5, 6));
//大小比較
Debug.Log(Mathf.ClosestPowerOfTwo(5));
//返回最近的2的次方數
cube.position = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update() {
//cube.position = new Vector3(Mathf.Clamp(Time.time, 1f, 3f), 0, 0);
//Mathf.Clamp,限定只在某個範圍之內,主要運用場景,控制血量藍量
//Debug.Log(Mathf.Clamp(Time.time, 1f, 3f));
float x = cube.position.x;
//float newx = Mathf.Lerp(x, 10, 0.1f);
// Mathf.Lerp按比例取兩者的之差
//float newx = Mathf.MoveTowards(x, 10, Time.deltaTime);
//Mathf.MoveTowards勻速移動
// cube.position = new Vector3(newx, 0, 0);
cube.position = new Vector3(Mathf.PingPong(Time.time*3, 10) - 5, 0, 0);
//Mathf.PingPong返回一個在0到10之間的數
}
}