- Home /
Bool is still false on another script even if it's its true onTriggerEnter2d
Hello guys, I check If something triggers on my platform. If so, i am making it true. But when i reach that on another script, it shows as false even if i trigger the collide (and in the trigger script, in turns true). Platform script works fine, i referenced it. My code basically needs to do: if its true, i will let it drop to area.
> private void Awake()
> {
> Instance = this;
> }
>
> public bool IsInsidePlatform { get; set; }
>
>
> private void OnTriggerEnter2D(Collider2D other)
> {
> IsInsidePlatform = true;
> }
>
> private void OnTriggerExit2D(Collider2D other)
> {
> IsInsidePlatform = false;
> Debug.Log("Leaving" + other.gameObject.name);
> }
*/// Another Script
if (Input.GetMouseButtonUp(0) && platform.IsInsidePlatform)
{
Debug.Log(platform.IsInsidePlatform); // returns false.need to return true.
_selected = false;
}
On Platform script, as you see its true. And on my another script in Update, if its true. it needs to place. But its not doing it. if i dont add platform.isInsiedPlatform, it works fine.
You could try making the variable static. Do you have the same reference to the object in the other script or is it different?
Your answer
![](https://koobas.hobune.stream/wayback/20220613041632im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make boolean be true for x amount of seconds? 2 Answers
How Activating a boolean fron another script(C#) 1 Answer
Multiple Cars not working 1 Answer
NetworkAnimator: SetBool vs. SetTrigget? 1 Answer
UI button doesn't appear - c# 3 Answers