I have a PickupTarget
object in front of my FirstPersonCharacter
which is used for 'holding' picked up object. Somehow, it doesn't work; when I click on the object (Axe
) it just stays on the ground.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PickUp : MonoBehaviour {
public Transform target;
void Update () {
}
void onMouseDown() {
this.transform.position = target.position;
this.transform.parent = GameObject.Find ("FirstPersonCharacter").transform;
}
void onMouseUp() {
this.transform.parent = null;
}
}
I have added PickupTarget
as a target
of script in Axe
object:
This is the structure of my Axe
object.