Ok, so first off, I’m embarrassed I even have to ask this. I pride myself on my good coding, but I can’t seem to figure out what’s wrong. The ball just rolls right through the cube without picking it up. Here’s my code:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "PickUp")
other.gameObject.SetActive(false);
}
}