合集-Unity
摘要:001_按键移动 Start()和Update() Start()游戏开始会调用一次 Update()每帧会调用一次 根据按键移动上下左右的位置 /* 根据按键移动上下左右的位置:每帧移动0.1 */ void Update() { //获取水平输入,按向左会获得-1.0f,按向右会获得1.0f f
阅读全文
摘要:002_移动速度 移动速度:单位/帧 public class RubyController : MonoBehaviour { // 在第一次帧更新之前调用 Start void Start() { //垂直同步计数设为0,才能锁帧,否则锁帧代码无效 //垂直同步的作用就是显著减少游戏画面撕裂、跳
阅读全文
摘要:003_碰撞消抖 通过获取刚体组件的位置消抖 public class RubyController : MonoBehaviour { // 将速度暴露出来,使其可调 public float speed = 4f; //声明刚体对象 Rigidbody2D rigidbody2D; //获取用户
阅读全文
摘要:004_生命修改和触发器 生命修改 using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Player
阅读全文
摘要:005_添加动画、子弹碰撞、无敌时间 RubyController using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using Un
阅读全文
摘要:006_2D Ruby 项目脚本 CogBulletController.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class CogBulletControlle
阅读全文