【发布时间】:2020-07-02 09:20:17
【问题描述】:
我试图让我的玩家从他的位置直接向我想要的方向射击,我做到了,但现在我有一个电影机,我希望它留在更大的背景区域,所以我添加到背景碰撞器它适用于相机边界但是 - 现在我正在拍摄的激光(它是动态的)与背景发生碰撞并且没有被拍摄。 我试图制作激光子弹运动学,但它只是实例化而不是远距离射击。
那么我怎样才能让我的激光子弹动态而不与背景碰撞呢?
我尝试了物理碰撞矩阵,但没有成功。
这里也是我的拍摄代码:
public Transform shootingPoint;
public GameObject laserPrefab;
[SerializeField] float projectileSpeed = 10f;
// Update is called once per frame
void Update()
{
if (CrossPlatformInputManager.GetButtonDown("Fire1"))
{
Shoot();
}
}
private void Shoot()
{
GameObject laser = Instantiate(laserPrefab, shootingPoint.position, shootingPoint.rotation);
Rigidbody2D rb = laser.GetComponent<Rigidbody2D>();
rb.AddForce(shootingPoint.up * projectileSpeed, ForceMode2D.Impulse);
}
【问题讨论】: