Mathf.Infinity 正无穷

static var Infinity : float

Description描述

A representation of negative infinity (Read Only).

表示正无穷,也就是无穷大,∞ (只读)[in'finiti]

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		Debug.DrawLine(Vector3.zero, Vector3.forward * 100);
		if (Physics.Raycast(Vector3.zero, Vector3.forward, Mathf.Infinity))
			print("There is something in front of the object!");

	}
}
// Casts a ray from (0,0,0) towards (0,0,1) to the infinity and prints a message
//画一条射线从(0,0,0) 向 (0,0,1)到无穷远,并打印一个消息
// if any object has touched the ray.
//如果任意物体碰到这个射线
// To test it, just place any object and intersect it with the white drawn line
//为便于测试,只需放置任意物体相交于白色的绘制线

function Update () {
	// shows the line that follows the ray.
	//显示这条射线
	Debug.DrawLine(Vector3.zero, Vector3.forward * 100);
	if (Physics.Raycast (Vector3.zero, Vector3.forward, Mathf.Infinity)) {
		print ("There is something in front of the object!");
	}
}
最后修改:2011年2月21日 Monday 11:37

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。