Whenever I start shooting, everything works out fine (the bullets come out, they go in a certain direction.) But for some reason when my character is in the air and fires, the bullet seems to hit him and he starts spinning.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletCtrl : MonoBehaviour {
public Vector2 bulletspeed;
[SerializeField]
private float delay;
Collider2D myCollider;
Rigidbody2D rb2d;
Collider2D coll;
// Use this for initialization
void Start ()
{
coll = GameObject.FindGameObjectWithTag ("Player").GetComponent<Collider2D> ();
myCollider = GetComponent<Collider2D> ();
rb2d = GetComponent<Rigidbody2D> ();
rb2d.velocity = bulletspeed;
Destroy (gameObject, delay);
}
// Update is called once per frame
void Update ()
{
rb2d.velocity = bulletspeed;
Physics2D.IgnoreCollision(coll, myCollider, true);
}
}
Thanks for taking a look at my problem.