热门

最新

红包

立Flag

投票

同城

我的

发布
less_duuuzx
Felix Du
2 年前
trueless_duuuzx

2024年诺贝尔奖公布时间
(转自公众号:科学宝)

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
using UnityEngine;public class SimpleShoot : MonoBehaviour{ public GameObject bulletPrefab; // 子弹预制体 public Transform firePoint; // 发射点 public float bulletSpeed = 20.0f; // 子弹速度 void Update() { if (Input.GetButtonDown("Fire1")) // 按下射击键 { Shoot(); } } void Shoot() { GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation) as GameObject; bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * bulletSpeed; }}
立即登录