当前位置:网站首页>Unity Day02
Unity Day02
2022-08-04 05:32:00 【漫漫有点方】
Day02
尝试了一下跳跃以及加速,跳跃使用up来调整位置,我猜想是因为没有写落地的代码,完全由unity本身的重力来进行落地导致的落地有时不稳开始平地摔。


加速功能只是进行了改变速度的大小。
之后调整了视角,并且设置了第一和第三人称。


代码段:
if (Input.GetKeyDown(KeyCode.V))
{
isTCamera = !isTCamera;
}
if (isTCamera)
{
tCamera.SetActive(true);
fCamera.SetActive(false);
}
else
{
fCamera.SetActive(true);
tCamera.SetActive(false);
}
同样的,对第三人称来设定滚轮缩放。(缩放后)

代码如下:
//变焦
float zoom = 1;
//监听
if (Input.GetAxis("Mouse ScrollWheel") < 0)
{
if (zoom < 1)
{
zoom += 0.1f;
}
}
else if (Input.GetAxis("Mouse ScrollWheel") > 0)
{
if (zoom > 0)
{
zoom -= 0.1f;
}
}
//Debug.Log(Input.GetAxis("Mouse ScrollWheel"));
//Y,Z的变化
//这里时进行缩放的相对距离
float f = Mathf.Lerp(2, 10, zoom);
//localposition相对坐标,position世界坐标
tCamera.transform.localPosition = new Vector3(0, f, -f);
//旋转X欧拉角
//这里是进行缩放的角度微调
float z = Mathf.Lerp(25, 45, zoom);
Vector3 v = tCamera.transform.eulerAngles;
v.x = z;
tCamera.transform.eulerAngles = v;
尝试把跳跃下落的问题解决,或者当摔倒后可以进行回正。
边栏推荐
猜你喜欢

No matching function for call to 'RCTBridgeModuleNameForClass'

Shell脚本执行的三种方式

Copy Siege Lion's Annual "Battle" | Review 2020

Golang environment variable settings (2)--GOMODULE & GOPROXY

LeetCode_Nov_3rd_Week

Question 1000: Input two integers a and b, calculate the sum of a+b, this question is multiple sets of test data

Brief description of database and common operation guide

枚举和联合(自定义类型)-C语言

Deep Learning Theory - Overfitting, Underfitting, Regularization, Optimizers

Pytest common plug-in
随机推荐
LeetCode_22_Apr_4th_Week
MVC自定义配置
arm学习-1-开发板
AWS uses EC2 to reduce the training cost of DeepRacer: DeepRacer-for-cloud practical operation
C语言对文件的操作(完整版)
Introduction to Convolutional Neural Networks
LeetCode_Dec_1st_Week
Windows10重置MySQL用户密码
安装pyspider后运行pyspider all后遇到的问题
MNIST handwritten digit recognition, sorted by from two to ten
EL表达式
[English learning][sentence] good sentence
使用cef离屏渲染技术实现在线教育课件和webrtc视频回放融合录制
[日常办公][ssh]cheatsheet
Shell基础
【五一专属】阿里云ECS大测评#五一专属|向所有热爱分享的“技术劳动者”致敬#
IDEA中创建web项目实现步骤
Chapter One Introduction
arm交叉编译
文件权限管理 ugo