I’m almost finish creating roll a boll. However a boll doesn’t collect cubes but just penetrate them. how can I fix it? Here is my code.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerControl : MonoBehaviour {
public float speed;
public Text countText;
public Text winText;
private Rigidbody rb;
private int count;
void Start() {
rb = GetComponent();
count = 0;
SetCountText();
winText.text = “”;
}
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 ("Pick UP"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText() {
countText.text = "Count:" + count.ToString();
if (count >= 12) {
winText.text = "You Win!";
}
}
}