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!");
	}
}
Page last updated: 2011-2-21