Basically when my casual collides with a coin it doesn’t increment the amount of coins variable for the 2 characters and it doesn’t destroy the coin. The character does collide with it but the coin acts as a wall at the moment.
public class Coins : MonoBehaviour {
public Transform playerMario;
public Transform playerLuigi;
public GameObject coin;
public int coinsMario;
public int coinsLuigi;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
OnCollisionEnter(Collision);
}
void OnCollisionEnter(Collision collision){
if(collision.gameObject.tag == "Mario"){
coinsMario += 1;
DestroyImmediate(coin);
}
if(collision.gameObject.tag == "Luigi"){
coinsLuigi += 1;
DestroyImmediate(coin);
}
}
}
If I try to put something in update it throws out an error such as
Argument #1' cannot convert
object’ expression to type UnityEngine.Collision', The best overloaded method match for
Coins.OnCollisionEnter(UnityEngine.Collision)’ has some invalid arguments and
Expression denotes a type', where a
variable’, value' or
method group’ was expected that’s with:
void Update () {
OnCollisionEnter(Collision);
}
any ideas?