【发布时间】:2020-06-22 02:36:27
【问题描述】:
我正在为两个玩家制作一个小型射手,每个人都可以射门。问题是当子弹高速飞行时,它的轨迹中有某些区域不会接触到物体,因此 OnTriggerEnter2d 在那里不起作用。这是子弹飞行脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet: MonoBehaviour
{
Rigidbody2d rb;
public int Player;
public float speed = 0.4f;
public Vector3 mode; // Direction of the bullet (Vector3.left, right)
// Start is called before the first frame update
void Start ()
{
rb = gameObject.GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void FixedUpdate ()
{
rb.velocity = mode * speed;
}
}
【问题讨论】:
-
那你想要什么?
-
如何解决??
-
试试这个:
Rigidbody2D > Collision Detection > Continuous -
此脚本中没有 OnTriggerEnter2D。你是故意删的吗?