Hello ! I searched on Google but I didn't find my problem's solution.
I'm creating a game, I've got a sphere, and that sphere (controlled by a joystick because it's a mobile game) has to move on a road and doesn't touch the oaks which are around the road. I did a script called "Collision" :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collision : MonoBehaviour
{
void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag == "Oak")
{
Destroy(gameObject);
}
}
}
This script is made in order to destroy the sphere when it touches the oak. The oak is tagged "Oak".
My oaks and my sphere have got a "RigidBody" (not 2D, this is a 3D game). That "RigidBody" hasn't got "Is Kinematic" checked.
I tried to change `Destroy(gameObject);` by `Debug.Log("Non!")` but this text doesn't appear in my console.
I hope that I gave you enough details to find out what's my problem and where's it !
Sorry if my English isn't good, I am out of English speakers' countries. :D
↧