最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【大概是最簡(jiǎn)單的unity教程】UP: Yu_Zhen

2023-02-22 20:20 作者:原野的天空biubiu怪  | 我要投稿


1、如何理解?


float x, z;

?x = Input.GetAxis("Horizontal");

z = Input.GetAxis("Vertical");


https://blog.csdn.net/weixin_44869410/article/details/103210842


在 void Update() 每一幀都會(huì)刷新,所以只有1,-1,0 三種情況。


鍵盤(pán)WASD,為例

W Z軸的前進(jìn) 1

S? Z軸的前后退 -1?


A X軸前進(jìn) 1 D同同理


2、


Vector3 mov;

mov = transform.right * x + transform.forward * z;

plyerMove.Move(mov*speed*Time.deltaTime);


?transform.right X軸的要移動(dòng)的方向?

?transform.forward Z軸的要移動(dòng)的方向?

*x *z 代表這個(gè)方向移動(dòng)的距離數(shù)值的大小


move 用來(lái)裝這個(gè)數(shù)據(jù)的一個(gè)結(jié)構(gòu)體

Move 移動(dòng)函數(shù)


3、cameraLook

a、鼠標(biāo)左右,人物移動(dòng) X軸

b、上下移動(dòng) Y軸 鏡頭移動(dòng)

public Transform player;

float x, y;

x = Input.GetAxis("Mouse X") * mouseSpeed*Time.deltaTime; //獲取鼠標(biāo)X軸數(shù)據(jù)

y = Input.GetAxis("Mouse Y") * mouseSpeed*Time.deltaTime;

player.Rotate(Vector3.up * x); // player 在unity掛載對(duì)象應(yīng)該是player這個(gè)對(duì)象


// 這里的this 是camera?

this.transform.localRotation = Quaternion.Euler(ymove,0,0);


P3

? ? //?

? ? public float speed;


? ? // 按一下空格 跳躍的高度 而不是速度

? ? public float jumpSpeed = 10;


? ? public float g = 10;


? ? public CharacterController plyerMove;


? ? public int jumpCount = 10;


? ? Vector3 move;

? ? // 二段跳

? ? // private int jumpOnAir = 0;

? ? // Start is called before the first frame update

? ? void Start()

? ? {

? ? ? ??

? ? }


? ? // Update is called once per frame

? ? void Update()

? ? {

? ? ? ? float x = 0, z = 0;


? ? ? ? if (plyerMove.isGrounded) {

? ? ? ? ? ? x = Input.GetAxis("Horizontal");

? ? ? ? ? ? z = Input.GetAxis("Vertical");

? ? ? ? ? ? move = (transform.right * x + transform.forward * z)*speed;

? ? ? ? ? ?jumpCount = 10;

? ? ? ? }


? ? ? ? if (isPressJump() && jumpCount >0)

? ? ? ? {

? ? ? ? ? ? move.y = jumpSpeed;

? ? ? ? ? ? // --的條件要改一下 限制 不能2幀全沒(méi)了

? ? ? ? ? ? jumpCount--;

? ? ? ? }


? ? ? ? // 為什么會(huì)掉落 應(yīng)該和這個(gè)計(jì)算方式有關(guān)

? ? ? ? // 為什么沒(méi)有這句就跳不起來(lái) 這是計(jì)算公式 一定要這樣帶

? ? ? ? move.y = move.y - g * Time.deltaTime;


? ? ? ? // move 向量 代表方向


? ? ? ? plyerMove.Move( move * Time.deltaTime );


? ? }


? ? bool isPressJump()?

? ? {? ?

? ? ? ? /*

? ? ? ? if (Input.GetAxis("Jump") == 1){

? ? ? ? ? ? return true;

? ? ? ? }

? ? ? ? else {

? ? ? ? ? ? return false;

? ? ? ? }*/


? ? ? ? return Input.GetAxis("Jump") == 1 ? true : false;

? ? }


【大概是最簡(jiǎn)單的unity教程】UP: Yu_Zhen的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
越西县| 南陵县| 冀州市| 仁怀市| 文山县| 奉节县| 镇平县| 资溪县| 吉林省| 微博| 赫章县| 怀集县| 浏阳市| 蓬莱市| 梅河口市| 桃园县| 奉节县| 松桃| 治县。| 泸定县| 河池市| 元氏县| 新津县| 多伦县| 茶陵县| 凤山市| 五河县| 福鼎市| 壤塘县| 故城县| 南召县| 黄石市| 阿鲁科尔沁旗| 格尔木市| 木兰县| 丰城市| 揭东县| 九寨沟县| 博客| 海城市| 邳州市|