当前位置:网站首页>unity3d-游戏物体控制方法
unity3d-游戏物体控制方法
2022-08-03 18:27:00 【liwulin0506】
键盘控制方向
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public Rigidbody rd;
// Start is called before the first frame update
void Start()
{
Debug.Log("1111111111111");
//rd = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
//transform.Rotate(Vector3.up * Time.deltaTime * 100);
float f = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
rd.AddForce(new Vector3(f,0,v)*1);
}
}
给prefab添加标签,检测碰幢和销毁物体
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag=="food")
{
Destroy(collision.gameObject);
}
}
触发检测
勾选collider中的istriigger,就变成了触发器
p边栏推荐
- 动态打印菱形
- Blender script 删除所有幽灵对象
- 字节跳动三面拿offer:网络+IO+redis+JVM+GC+红黑树+数据结构,助你快速进大厂!!
- 大佬,谁有空帮忙看下这个什么问题呢,我就读取MySQLsource print下,刚接触flink,
- CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes), problem: (D) Magical Array
- tree命令:以树的形式列出目录中的文件
- Big guy, who is free to help me to see what the problem is, I just read MySQL source print, and I just came into contact with flink.
- BigInteger :new BigInteger(tokenJson.getBytes()).toString(16)什么意思
- PHP Basic Notes-NO.2
- 异常与智能指针
猜你喜欢
随机推荐
PHP Basic Notes-NO.2
Postgresql 备份大小情况!
select......for update 语句的功能是什么? 会锁表还是锁行?
爬虫之selenium
6000 字+,帮你搞懂互联网架构演变历程!
学弟:我适不适合转行做软件测试?
fatal error: jni.h: No such file or directory
Chrome浏览器开发新截图工具,安全浏览器截图方法
揭秘deepin 23,从这里开始!
Uniswap或将开启“费用开关”,UNI持有者可享受分红
ROS仿真环境搭建
借助kubekey极速安装Kubernetes
架构基本概念和架构本质
tree命令:以树的形式列出目录中的文件
云图说丨初识华为云微服务引擎CSE
基于PHP7.2+MySQL5.7的回收租凭系统
ASA归因:如何评估关键词的投放价值
基于ck+redash构建MySQL慢日志+审计日志展示平台
Oracle 脚本实现简单的审计功能
程序员如何分分钟搞垮一个项目?









