当前位置:网站首页>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边栏推荐
猜你喜欢

Shell编程案例

【白话模电2】二极管特性和分类

87. (Home of cesium) cesium heat map (topography)

爬虫之selenium

InnoDB 中不同SQL语句设置的锁

MySQL——增删改查进阶

Postgresql 备份大小情况!

Weekly recommended short video: In order to fill the gap of learning resources, the author specially wrote a book?

多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG

MD5是对称加密还是非对称加密,有什么优缺点
随机推荐
常见荧光染料修饰多种基团及其激发和 发射波长数据一览数据
EasyNTS上云网关断电重启后设备离线是什么原因?
Higher mathematics - chapter ten infinite series - constant term series
借助kubekey极速安装Kubernetes
POJ 1465 Multiple(用BFS求能组成的n的最小倍数)
异常与智能指针
[数据集][VOC]老鼠数据集voc格式3001张
87.(cesium之家)cesium热力图(贴地形)
MySQL如何一劳永逸的永久支持输入中文
Gson 学习笔记
高数---级数
InnoDB 中不同SQL语句设置的锁
如何成为优秀的产品运营?
Share 14 JS functions you must know
Uniswap或将开启“费用开关”,UNI持有者可享受分红
pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx
理想L9旗舰级的安全性有多强?守护一家人安全出行“底线”
三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8
【美丽天天秒】链动2+1模式开发
ImportError: /lib/libgdal.so.26: undefined symbol: sqlite3_column_table_name