找回密碼
 注冊帳號

掃一掃,訪問微社區

charactercontroller.velocity 速度

2015-1-4 12:07| 發布者: 楊炎| 查看: 2255| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: charactercontroller.velocity 速度varvelocity:vector3description描述the current relative velocity of the character (see notes).角色當前的相對速度(參見注解)。this allows you to track how fast the char ...

charactercontroller.velocity 速度

varvelocity:vector3

description描述

the current relative velocity of the character (see notes).

角色當前的相對速度(參見注解)。

this allows you to track how fast the character is actually walking for example when he is stuck at a wall this value will be the zero vector.

它允許你追蹤角色究竟移動有多快,例如,當他被卡在墻壁里,這個值將變為0向量。

note: the velocity returned is simply the difference in distance for the current timestep before and after a call to charactercontroller.move or charactercontroller.simplemove. the velocity is relative because it won't track movements to the transform that happen outside of the charactercontroller (e.g. character parented under another moving transform, such as a moving vehicle).

注解:返回速度在調用charactercontroller.move或者charactercontroller.simplemove之前和之后的時刻是不同的。速度是相對的,因為它不會追蹤發生在charactercontroller之外的變換的運動(例如,角色繼承于另一個運動著的變換之下,比如一個運動著的車輛)。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

void update() {

charactercontroller controller = getcomponent();

vector3 horizontalvelocity = controller.velocity;

horizontalvelocity = newvector3(controller.velocity.x, 0, controller.velocity.z);

float horizontalspeed = horizontalvelocity.magnitude;

float verticalspeed = controller.velocity.y;

float overallspeed = controller.velocity.magnitude;

}

}

function update () {

var controller : charactercontroller = getcomponent(charactercontroller);

var horizontalvelocity :vector3= controller.velocity;

horizontalvelocity =vector3(controller.velocity.x, 0, controller.velocity.z);

// the speed on the x-z plane ignoring any speed

//忽略y軸的x-z平面上的速度。

var horizontalspeed : float = horizontalvelocity.magnitude;

// the speed from gravity or jumping

//重力或者跳躍引起的速度。

var verticalspeed : float = controller.velocity.y;

// the overall speed

//總體速度。

var overallspeed : float = controller.velocity.magnitude;

}

相關閱讀

文章點評
相關文章
极速时时彩开奖最快的网站