Hello, I’m having a problem. I have bullets which are destroyed when they collision with a wall or something. This works fine but it doesn’t look well, you can see how the bullet goes through the wall for a second.
I have tried to change the collision detection to continuous, but it doesn’t make any difference.
Hola, estoy teniendo un problema. Tengo balas que son destruidas al momento de colisionar con una pared o cualquier otra cosa. Esto funciona bien, sin embargo, el efecto no queda bien. Se llega a ver como la bala traspasa la pared por un momento y después se destruye.
Ya intente cambiar la detección de colisiones a continua, pero no cambia nada.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletMovement : MonoBehaviour
{
public float speed;
void Start()
{
}
void Update()
{
transform.Translate(speed*Time.deltaTime, 0, 0);
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (!collision.gameObject.CompareTag("Player"))
{
Destroy(gameObject);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (!collision.gameObject.CompareTag("Player"))
{
Destroy(gameObject);
}
}
}