- Home /
Question by
azfar faheem · Jun 21, 2015 at 10:57 AM ·
collidingcollectible-game-objectsno errors
in the project roll the ball while COLLECTING THE PICK UP OBJECTS the ball goes through and dosen't pick up the object
i have entered the code,done the trigger part using the prefab ,checked if all are in prefab and checked if the code is applied ,i cant find any mistakes in my code please help me find any mistake and solve this here is my code:
using UnityEngine;
using System.Collections;
public class playercontrol : 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("Pick Up"))
{
other.gameObject.SetActive (false);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
I am having a problem with detecting certain collision? 1 Answer
differentiate between box collider of two different Game Objects in UNITY 1 Answer
can't detect what player collides with, tried everything and all other posts... 2 Answers
object not colliding with another object,,.but getting merged and passing each other. 2 Answers
How to Make an Object Pickup System? 0 Answers