Well. I am constructing a 3D point n click slice as a project in Unity with C#. It isn't meant to be complicated, and rather I have made it as simple as possible, to try and make it manageable for myself. I am struggling with this script, to try and make an object (That will later be an animated model) interactable. The idea is that you click on the object, said object goes inactive (aka dissapear) while another model appears somewhere else. And then the opposite, when you click on the new object However, the script is not working and I am not 100% sure what I am doing wrong.
My basic script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ModelSpawnDespawn : MonoBehaviour
{
private GameObject SittingGuyc;
private GameObject StandingGuyc;
private void OnMouseUpAsButton()
{
if(isActiveAndEnabled)
{
SittingGuyc.SetActive(false);
StandingGuyc.SetActive(true);
}
}
}
I am very new to programming, so this isn't very complicated and I am sure it is just something basic that I have missed. But I can't seem to find what I did wrong and would love some solid advice from a good community.
SittingGuycandStandingGuyc? Where do these come from? and is it possible that this component is attached to the one you set to inactive so it is no longer listening?