当前位置:网站首页>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边栏推荐
- 【mysql】SIGN(x) function
- 基于ck+redash构建MySQL慢日志+审计日志展示平台
- 不要小看 WebSocket!长连接、有状态、双向、全双工都是王炸技能
- SQL代码需要供其他人复用,为什么传统的复制代码不可靠?
- 87.(cesium之家)cesium热力图(贴地形)
- cdc抽取mysql整个实例的binlog,有没有方案通过配置的方式将这些库表拆开分发到kafka
- ImportError: /lib/libgdal.so.26: undefined symbol: sqlite3_column_table_name
- 借助Web3盘活日本优质IP:UneMeta 与 OpenSea 的差异化竞争
- 15、学习MySQL NULL 值处理
- 5v2.1a给5v2a充电行吗
猜你喜欢

vulnhub pyexp: 1

Higher mathematics - chapter ten infinite series - constant term series

Jenkins CI平台(二)

CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes), problem: (D) Magical Array

MPLS的简单应用于实验

基于ck+redash构建MySQL慢日志+审计日志展示平台

安装porterLB

rhel8.3 系统下修改有线网卡配置信息实现联网

LineSegmentTree线段树

阿里资深专家打造从零开始学架构,含阿里内部技术栈PPT、PFD实战
随机推荐
【白话模电2】二极管特性和分类
H.265网页播放器EasyPlayer获取视频流正常,但是播放出现黑屏是什么原因?
5000元价位高性能轻薄本标杆 华硕无双高颜能打
select......for update 语句的功能是什么? 会锁表还是锁行?
Postgresql 备份大小情况!
rhel8.3 系统下修改有线网卡配置信息实现联网
不要小看 WebSocket!长连接、有状态、双向、全双工都是王炸技能
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.
深度学习常用公式与命令总结(更新中)
Selenium of reptiles
什么是鉴权?一篇文章带你了解postman的多种方式
15、学习MySQL NULL 值处理
如何成为优秀的产品运营?
我们为何看好投资 DAO?
懵逼!阿里一面被虐了,幸获内推华为技术四面,成功拿到offer,年薪40w
openresty 高可用部署
Uniswap或将开启“费用开关”,UNI持有者可享受分红
ASA归因:如何评估关键词的投放价值
一文搞懂│php 中的 DI 依赖注入
大佬们,flinkcdc 2.2 版本采集sqlserver只能采集到全量的数据,不能采集到增量的数