I am making a 2d platformer and I almost have the shooting completely working, but I can’t figure out how to get my Physics.IgnoreCollision to work, because its keeps saying both colliders need to be activated. So I assume I am calling the prefab projectile instead of the new clones being instantiated. But how do I call the clones instead of the prefab.
using UnityEngine;
using System.Collections;
public class Shooter : MonoBehaviour {
public Rigidbody projectile;
public Transform shotPos; //attatched to player
public float shotForce = 1000f;
public float moveSpeed = 10f;
//Mouse Following
private Vector3 mousePos;
public Transform target;
private Vector3 objectPos;
private float angle;
public GameObject player;
void Update (){
mousePos = Input.mousePosition;
mousePos.z = -20; //distance between camera and object
objectPos = Camera.main.WorldToScreenPoint (target.position);
mousePos.x = mousePos.x - objectPos.x;
mousePos.y = mousePos.y - objectPos.y;
angle = Mathf.Atan2 (mousePos.y, mousePos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler (new Vector3(0, 0, angle));
if(Input.GetButtonUp("Fire1")){
Rigidbody shot = Instantiate(projectile, shotPos.position, shotPos.rotation) as Rigidbody;
shot.AddForce(shotPos.right * shotForce);
}
Physics.IgnoreCollision (projectile.collider, player.collider); //Here is where I am having problems, code works fine but this is giving me an error in the console
}
}
Thank you all help is greatly appreciated!