Question by
ameeraizat104 · May 26, 2020 at 08:11 AM ·
drop
How to drop to specific position?
using UnityEngine; using System.Collections;
public class TakeMe : MonoBehaviour {
private Transform taker;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("t"))
{
transform.parent = taker;
}
else if (Input.GetKeyDown("g"))
{
transform.parent = null;
}
}
void OnTriggerEnter(Collider col)
{
if (col.CompareTag("Player"))
{
taker = col.transform;
}
}
void OnTriggerExit(Collider col)
{
if (col.CompareTag("Player"))
{
taker = null;
}
}
}
Comment