• 周三. 4 月 22nd, 2026

物嫩软件资讯网

软件资讯来物嫩

Unity3D学习记录——飞盘射击游戏2

admin@wunen

5 月 2, 2025

1.这是完善后带有页面逻辑的游戏,界面如下

2.在ShooterWeapon中集成了分数计算,和计时器

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShooterWeapon : MonoBehaviour {
    
    private Transform m_transform; //变换组件对象,用于指向-物理射线碰撞点
    private static LineRenderer m_line; //线渲染器用于制作制作激光特效
    public Transform m_weapontrans; //先创建了空物体,用于定位枪口位置,最终为激光亮点定位
    private AudioSource m_shootaudio; //射击音效

    private bool canmove = false; //用于游戏开始前让射击动作无法执行
    private AudioSource m_background; //背景音频对象,使在游戏开始前不播放

    private float timer = 10.0f; //用作游戏倒计时
    private GUIText ui_timer; //用于游戏界面显示倒计时 
    private int score = 0; //用于计算得分
    private GUIText ui_score;

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注