本文已参与「新人创作礼」活动,一起开启掘金创作之路
第一次用掘金平台,感觉页面设计好酷!!!!!,以后要更努力的创作博文啦!今天就浅发一下自己学Unity的第一天内容小记录吧,后面其实可能会更偏向于J2EE的相关内容
进了一个工作室,选择的方向是硬件组,冲!!!!
第一个项目:用Kinect做一个小项目,实现交互,我们小组最后选择了先单纯做一个好玩的游戏吧,开始学习怎么用Unity,加油吧
先选择了大佬的经验,试着慢慢尝试
先建立一个cube,调整位置,增加光源
再新建一个cube
添加刚体,运行
嗯,把c#程序给cube,差不多了
金......好多错
是我菜了
先更到这吧,呜呜呜,疯狂qwq
———————————————————————————————— 分割线
芜湖,找大佬改完了,成功!!!!
可以进行动作啦
下面是源代码
using System.Collections.Generic;
using UnityEngine;
public class li : MonoBehaviour
{
//定义移动的速度
public float MoveSpeed = 2f;
//定义旋转的速度
public float RotateSpeed = 0.01f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//如果按下W或上方向键
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
{
//以MoveSpeed的速度向正前方移动
this.transform.Translate(Vector3.forward * MoveSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
{
this.transform.Translate(Vector3.back * MoveSpeed * Time.deltaTime);
}
//如果按下A或左方向键
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
//以RotateSpeed为速度向左旋转
this.transform.Rotate(Vector3.down * RotateSpeed);
}
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
this.transform.Rotate(Vector3.up * RotateSpeed);
}
}
}