I have player interact script for picking up and dropping stuff. I wanted to add a hover “Press E” whatever too let the players know what they can an cannot pick up. Didn’t want the basic button style bc it looks bad. Long story short I figured out that I could use Canvas Groups to fade in and out with the alpha. The only problem is (even when I am calling different Canvas Groups) all canvas groups will fade in and out.
Before I hover over, only the canvas in the said hitting parent should enable:
After Raycast hits… both canvas groups alpha to 1.
This is the anvil script setting:

This is the cube you see on the left settings:

This is what goes on the item I want to grab. really just wanna know why it is calling all Canvas Groups and not the one I set.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hover : MonoBehaviour {
public GameObject player;
public CanvasGroup canvas;
public float speed;
public bool holdingCanvas;
// Update is called once per frame
void Update () {
if (player.GetComponent<Holdable> ().hit.collider == null) {
leaveTip ();
}
if (player.GetComponent<Holdable> ().holding != false) {
if (player.GetComponent<Holdable> ().hit.collider.tag != "item") {
leaveTip ();
}
}
if (player.GetComponent<Holdable> ().holding == true) {
if (player.GetComponent<Holdable> ().hit.collider.tag == "item" && player.GetComponent<Holdable> ().hit.collider != null) {
leaveTip ();
}
}
if (player.GetComponent<Holdable> ().Hitt == true) {
if (holdingCanvas == false) {
if (player.GetComponent<Holdable>().hit.collider.tag == "item") {
speed = 5 * Time.deltaTime;
canvas.alpha += (speed);
}
}
}
}
void leaveTip(){
speed = 5 * Time.deltaTime;
canvas.alpha -= (speed);
holdingCanvas = true;
}
}

