找回密碼
 注冊帳號

掃一掃,訪問微社區

charactercontroller.velocity 速度

2015-1-4 12:07| 發布者: 楊炎| 查看: 1976| 評論: 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;

}

相關閱讀

文章點評
相關文章
女校游泳队彩金 2019零投资最靠谱赚钱的方法 公司狗年拜年词赚钱如割草 2020年最赚钱的职业排名 赚钱app可信么 迪士尼做导游赚钱吗 新版奇迹mu赚钱攻略 高空挑战能赚钱吗 用微信号能赚钱吗 送外卖真的很赚钱吗 微帮靠什么赚钱 2014年什么最赚钱 在郑州开安装led屏赚钱吗 收废塑料能赚钱吗 瑜伽柠檬 老师赚钱 看见怎么赚钱 卖切糕赚钱吗