- Home /
Make a prefab gameobject trigger on dropping gameobject upon it
Hi!
I wonder if it's possible to have a prefab/gameobject to trigger when another object is dropped on it. Like in this image:
http://i.imgur.com/8T5mKfN.png
I have all these placeholder where to drop other objects. I need to be able to receive the dropped object and put it in a local property (lifeLine). Would that be possible?
This is just my test code so far:
using UnityEngine;
using System.Collections;
public class LifelinePlaceholder : MonoBehaviour {
public GameObject lifeLine;
public string Name;
// Use this for initialization
void Start () {
Debug.Log ("Yeah!");
}
// Update is called once per frame
void Update () {
}
void OnMouseUp()
{
Debug.Log (Name);
//Debug.Log ("foobar");
}
void OnTriggerEnter2D(Collider2D other) {
Debug.Log(other.gameObject);
}
void OnCollisionEnter2D(Collision2D other){
Debug.Log(other.gameObject);
}
}
Thanks in advance!
Answer by deamo · Mar 25, 2014 at 10:41 PM
After some research I found the answers I needed :) Works great now!
Your answer
Follow this Question
Related Questions
Script Not Working On Prefab 2 Answers
Prefab "Disappears" On Game Restart [Fixed!] 0 Answers
Script uses transform.position of Prefab instead of Instance 1 Answer
Getting Prefab Icon from AssetDatabase 0 Answers
Predefined Dynamic Navmesh? (With image) 0 Answers