I have a invicible GameObject called trigger, and when my Hero collides with it, a chandelier falls.
I want to give the chandelier a Rigidbody so it falls, and you can collide with it and maybe use it.
If you can explain to me how collision works and show how to do something if to gameObject collides its would realy cool still new at Unity.
using UnityEngine;
using System.Collections;
public class Collider : MonoBehaviour {
public GameObject chandelier;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
//When my hero collides with trigger go to the fall function
void OnTriggerEnter (Collider other) {
if (other.tag == "Trigger")
{
fall();
}
}
//Add Rigidbody to the GameObject called chandelier
void fall ()
{
chandelier.rigidbody.AddForce(1, 1, 1);
}
}