Hi,
I am a beginner on Unity3D. I am working on Roll a ball tutorial.
When tested the Colliding part, the collectible cube is not deactivated even after player has collided with these cubes. Instead player will pass through them. Check the picture attached.
Below is the code:
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start(){
rb = GetComponent<Rigidbody> ();
}
void FixedUpdate(){
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
void onTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("PickUpCube")) {
other.gameObject.SetActive (false);
}
}
}
Not sure how to resolve this. Require help.
Thank you!