#Unity is being demented, an object is invisible and I cant assign the things I reffrenced object

1 messages · Page 1 of 1 (latest)

cyan kiteBOT
#

Before others can help, a clear question must be formulated

When you ask a difficult question it is your responsibility to ensure that anyone reading it will have all of the information they need to understand and diagnose the problem. Sometimes questions aren’t as clear to others as they could be or they may be missing critical information needed to provide a correct answer.
Source: https://idownvotedbecau.se/unclearquestion

Please elaborate on your question by including all the relevant information such as:

  • The programming language within which you're working (if it is anything other than C#)
  • Exactly what it is you're trying to accomplish
  • Things you have considered/attempted already
  • Anything else that could aid answerers in resolving the issue
oak flicker
#

anyways

#

let me post the things

#

this is how it looks in the scene view

#

the brown object is the one im reffering to

#

this is in game view

#

its not there

#

I cant reffrence it without an instance being in the scene

#

I didnt have that problem for other objects

#

I basically copy pasted code

#

and adjusted

#
using System.Collections.Generic;
using UnityEngine;

public class HpBottle : MonoBehaviour
{
    [SerializeField] playerHealth hp;
    [SerializeField] HealthBar hpbar;

    private void Start()
    {
        hp = FindObjectOfType<playerHealth>();
        hpbar = FindObjectOfType<HealthBar>();
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.name == "Player")
        {
            Destroy(gameObject);
            hp.health += 5f;
            hpbar.slider.value += 5f;


        }
    }



}
#

this is the code where it needs to be assigned

oak flicker
#

the second problem I fixed idk how

#

but the first one persists