i have 2 objects… one is named Block and the other is Hole… The block has 4 child empty objects that have box colliders with custom sizes, according to need… The hole object has a rigidbody, with gravity=false, and a box collider with isTrigger=true… for each child object in the BLOCK object, there is a code for movement when mouse is clicked on it…
When the block enters the hole object, it does not trigger the OnTriggerEnter function… what do i do?
using UnityEngine;
using System.Collections;
public class StopBlockMovement : MonoBehaviour {
// Use this for initialization
void Start(){}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
Debug.Log("a");
}
I tried this on script on both items does not show collision…
script for movement in the child empty objects is:
bool pressed=false;
// Use this for initialization
void Start(){}
// Update is called once per frame
void Update()
{
if(pressed==true)
{
transform.parent.Translate(Vector3.down*Time.deltaTime*2);
}
if(transform.parent.position.y<-6.5)
{
Destroy(transform.parent.gameObject);
}
}
void OnMouseDown()
{
pressed = true;
}