bounds.intersectray 相交射线?

2015-1-3 20:07| 发布者: 杨炎| 查看: 2707| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本manual

摘要: bounds.intersectray 相交射线?functionintersectray(ray:ray) : booldescription描述does ray intersect this bounding box?射线与这个边界框相交么?c#javascriptusing unityengine;using system.collections;pub ...

bounds.intersectray 相交射线

functionintersectray(ray:ray) : bool

description描述

does ray intersect this bounding box?

射线与这个边界框相交么?

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

publicrayra = new ray(vector3.zero,vector3.forward);

void update() {

debug.drawray(vector3.zero,vector3.forward* 999,color.green);

bounds bounds = transform.collider.bounds;

if (bounds.intersectray(ra))

debug.log("touched the ray");

}

}

// creates a ray that points from the origin to the infinity among the z axis.

// and prints if the transform touched the ray.

//沿着z轴,从原点到无限远,创建一条射线

//并且如果变换碰到射线,打印消息

var ra :ray= new ray (vector3.zero,vector3.forward);

function update () {

// color ra in the scene editor.

//在场景编辑器,给射线一个颜色

debug.drawray(vector3.zero,vector3.forward* 999,color.green);

var bounds : bounds = transform.collider.bounds;

if (bounds.intersectray (ra))

debug.log("touched the ray");

}

o functionintersectray(ray:ray,out distance: float) : bool

description描述

does ray intersect this bounding box?

射线与这个边界框相交么?

when intersectray returns true distance will be the distance to the ray's origin.

当intersectray返回真,距离将是到射线原点的距离。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

publicrayra = new ray(vector3.zero,vector3.forward);

public float t = 10.0f;

void update() {

debug.drawray(vector3.zero,vector3.forward* 10,color.green);

bounds bounds = transform.collider.bounds;

if (bounds.intersectray(ra, ref t))

debug.log("touched the ray");

}

}

// creates a ray that points from the origin to 10 units among the z axis.

// and prints if the transform touched the ray.

//沿着z轴,从原点到10个单位之间,创建一条射线

//并且如果变换碰到射线,打印消息

var ra :ray= new ray (vector3.zero,vector3.forward);

var t : float = 10.0;

function update () {

// color ra in the scene editor.

//在场景编辑器,给射线一个颜色

debug.drawray(vector3.zero,vector3.forward* 10,color.green);

var bounds : bounds = transform.collider.bounds;

if (bounds.intersectray (ra, t))

debug.log("touched the ray");

}

相关阅读

文章点评
相关文章