找回密碼
 注冊帳號

掃一掃,訪問微社區

charactercontroller.simplemove 簡單移動

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

摘要: charactercontroller.simplemove 簡單移動functionsimplemove(speed:vector3) : booldescription描述moves the character with speed.以一定的速度移動角色。velocity along the y-axis is ignored. speed is in met ...

charactercontroller.simplemove 簡單移動

functionsimplemove(speed:vector3) : bool

description描述

moves the character with speed.

以一定的速度移動角色。

velocity along the y-axis is ignored. speed is in meters/s. gravity is automatically applied. returns if the character is grounded. it is recommended that you make only one call to move or simplemove per frame.

y 軸上速度被忽略。速度以米/秒為單位。重力被自動應用。返回如果角色著地。建議你每幀只調用一次move或者simplemove。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

public float speed = 3.0f;

public float rotatespeed = 3.0f;

void update() {

charactercontroller controller = getcomponent();

transform.rotate(0, input.getaxis("horizontal") * rotatespeed, 0);

vector3 forward = transform.transformdirection(vector3.forward);

float curspeed = speed * input.getaxis("vertical");

controller.simplemove(forward * curspeed);

}

}

var speed : float = 3.0;

var rotatespeed : float = 3.0;

function update () {

var controller : charactercontroller = getcomponent(charactercontroller);

// rotate around y - axis

//圍繞y軸旋轉

transform.rotate(0, input.getaxis ("horizontal") * rotatespeed, 0);

// move forward / backward

//向前后移動

var forward :vector3= transform.transformdirection(vector3.forward);

var curspeed : float = speed * input.getaxis ("vertical");

controller.simplemove(forward * curspeed);

}

@script requirecomponent(charactercontroller)

文章點評
送書《UE材質完全學習教程》!
女校游泳队彩金 福建快3走势图一定牛前往移漏 熊猫四川麻将安卓版 贵阳麻将下载 广西快乐十分分析 快乐8 新疆11选5走势图手机板 3d试机号关注号 瑞典vs瑞士大比分预测 长沙麻将打牌技巧 广东十一选五万能码 好彩1开奖结果查询 子基金配资 海口按摩多少钱 股票购买规则 SM捆绑影吧 分分彩0369规律技巧