When I click on the trigger
It is showing missing reference exception, i Cant seem to figure it out
this is my bullet code:
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
public class bullet : MonoBehaviour
{
[SerializeField] float bulletspeed = 20f;
[SerializeField] float xspeed = 1f;
playermovemet player;
Rigidbody2D myrigidbody;
void Start()
{
myrigidbody = GetComponent<Rigidbody2D>();
player = FindObjectOfType<playermovemet>();
xspeed = player.transform.localScale.x * bulletspeed;
}
void Update()
{
myrigidbody.velocity = new Vector2(xspeed,0f);
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "enemy")
{
Destroy(other.gameObject);
}
}
void OnCollisionEnter2D(Collision2D other)
{
Destroy(gameObject);
}
}