热门

最新

红包

立Flag

投票

同城

我的

发布
2402_87886424
小熊软糖酱۹(๑•̀ω•́๑)۶
2 年前
true2402_87886424

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;
}
}

CSDN App 扫码分享
分享
1
点赞
打赏
  • 复制链接
  • 举报
下一条:
今日打卡
立即登录