当前位置:网站首页>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边栏推荐
- openresty 高可用部署
- 2022/08/02------丑数
- InnoDB 中不同SQL语句设置的锁
- 5v2.1a给5v2a充电行吗
- PHP base notes - NO. 1
- 6000 字+,帮你搞懂互联网架构演变历程!
- 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.
- 二叉树求和路径问题解答与注记
- 懵逼!阿里一面被虐了,幸获内推华为技术四面,成功拿到offer,年薪40w
- Redis:哨兵
猜你喜欢
随机推荐
LeetCode - 102. 二叉树的层序遍历;110. 平衡二叉树;098. 验证二叉搜索树
AI智能剪辑,仅需2秒一键提取精彩片段
智能合约安全——delegatecall (2)
es6新增-async函数(异步编程的最终解决方案)
技术开发人员常用的安全浏览器
Online monitoring of UPS power supply and operating environment in the computer room, the solution is here
[数据集][VOC]老鼠数据集voc格式3001张
ImportError: /lib/libgdal.so.26: undefined symbol: sqlite3_column_table_name
yaml data format
5000元价位高性能轻薄本标杆 华硕无双高颜能打
Selenium of reptiles
多商户商城系统功能拆解21讲-平台端分销订单
大佬们,flinkcdc 2.2 版本采集sqlserver只能采集到全量的数据,不能采集到增量的数
云渲染的优势与劣势
2022/08/02------丑数
调用EasyCVR云台控制接口时,因网络延迟导致云台操作异常该如何解决?
warnings.warn(“Title is more than 31 characters. Some applications may not be able to read the file
cdc抽取mysql整个实例的binlog,有没有方案通过配置的方式将这些库表拆开分发到kafka
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) A-E
OSError: [WinError 123] 文件名、目录名或卷标语法不正确









