1r Program:
using UnityEngine;
public class PickUpObjects : MonoBehaviour
{
public GameObject ObjectToPickUp;
public GameObject PickedObject;
private void Update()
{
if (ObjectToPickUp != null && ObjectToPickUp.GetComponentInParent().isPickable == true && PickedObject == null)
{
if (Input.GetKeyDown(KeyCode.E))
{
PickedObject = ObjectToPickUp;
PickedObject.GetComponent().isPickable = false;
Interact();
}
}
}
public virtual void Interact()
{
Debug.Log(“j”);
}
}
2n Program:
using UnityEngine;
public class PickableObject : PickUpObjects
{
public Item item;
public bool isPickable = true;
public override void Interact()
{
Debug.Log(“s”);
base.Interact();
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == “PlayerInteractionZone”)
{
other.GetComponentInParent().ObjectToPickUp = this.gameObject;
}
}
private void OnTriggerExit(Collider other)
{
if (other.tag == “PlayerInteractionZone”)
{
other.GetComponentInParent().ObjectToPickUp = null;
}
}
}
The public override void doesn’t works. The letter “J” in the first program comes out on the console of Unity, but the letter “S” not.
Anyone can tell me why? Thanks.