Download

Change Index with Custom Event ...

I want that if my character picks up an object that is shown in the form of an image in the HUD. I have done most of it, but I cannot address the index value either with a custom event or in any other way - I have marked the index value in red in the picture below Index Integer: -0- Default -1- Pic 1 -2- Pic2 How can I change the images using the index value? Sample (Doesnt work): Lool Pic4 Pls Help :frowning:

Look at the NOTE under the “Cast to HUD” node.
I’m guessing it says the types are incompatible; it means the type of variable “HUD Ref” is not and probably can’t be an “HUD”.

You didn’t show any picture of you setting the variable either

When casting, do you always need a reference or not? - here I have created a reference variable from the HUD - I always have this “note” but it usually works

Yes you always need an object reference when casting otherwise it will always fail.

You don’t always need to cast though which is probably what the Note is telling you. Casting is only necessary when you want to DownCast or UpCast. DownCasting or Casting is what you normally do when you have a parent reference and you want to Cast it down to a child eg. Actor cast to Animal. UpCasting is the other way when you have a child reference and want to UpCast to a parent eg. Cat cast to Actor.

Referencing an image by an index is possible but leads to errors because the index becomes a “magic number” that no-one knows what is without opening the functions and peek inside. Why not use the ImageSelector struct instead?

Your actual problem is probably that you never Set HudRef to anything so it points at nothing and the Cast always fails.