Download

accessing an objects tags

I’ve set up multiple objects with a gameplay tag describing each one, I’m not sure how to apply tags but I’ve made a tag container variable in each object and set the tags in there and looking in the class defaults is says the tags have been applied, but when I try to use a gameplay tag switch it fails to recognise them. Am i doing something wrong? Heres my setup:


When given an object with the tag Grabbable.Ball in its tag container it responds “object has no tags” as its told to do in case 0, when no tags are pressent. Heres what my objects look like:


I’m not really sure what I’m doing wrong here, my old guess would be the switch is looking for the wrong thing or I should be using a gameplay tag switch rather than a gameplay tag container switch but I’m unable to get only the tags from the object I’m given and can only get a container from it

any help or advice would be appreciated, I’m pretty stuck!

thanks

Why not just using the default Epic tag system?

actor.JPG

also in BP.

I need to be able to sort them through a switch and I don’t think there’s a switch for normal tags
c2pD2m4JS0.png

Like this:

EDIT: Uh, this is also an Epic system - did not know about it… ( gameplay tags ). Will have a rummage.

oh nice, thanks, I’ll try out this system tho I think unreal engine sometimes changes names to work stuff so it might break, I remember seeing someone saying using names was a bad idea but that might have only been object names

Ok, RE: your original query… I think you need to break the tag out before using the switch:

or, use queries as in:

It seems a bit cumbersome to me.

No these are not names in that sense. The variable type is ‘name’, yes, but the tags are whatever you want to put in there. I use it all the time, no problem.

Using the name of objects you see in the editor, separate thing. Probably not a good idea.

It’s not as elaborate as this gameplay tag system, but unless you specifically want hierarchical complexity like that, I’d stick with plain old tags.

Oh nice, thank you! This has had me stumped for a decent few hours, yea my original system read the objects name and the editor kept adding numbers on the end of it breaking my system

ok

ok weird, I tried breaking it and i got the same issue but printing out the name of the tag at index 0 says the name of the tag is notag so I’d assume the tags havent been set properly or cant be retrieved

I’ve tried not using a tag container either and i have the same issue

Do you have a specific reason for using gameplay tags? Can you do it with ‘normal’ tags?

I cant find any documentation for normal tags online anywhere, are they easy enough to use I wouldn’t need it?

also trying it at the moment, I cant get tags from anything other than actors and I’m giving it an object
CCu1PjZ3yF.png

Tags are all over the place. On an actor you can add both actor and component tags. In BP, you only have component tags.

This is a cube in the level, seen from the level BP:

tags.JPG

ah ok, i think I’ve got it working, this has actually been super helpful. thanks for putting up with me lol

Excellent! - just come back if you get stuck :slight_smile:

By default, the “Get Owned Gameplay Tags” interface returns a tag container that is empty. To utilize this function, you’ll have to override the interface in cpp.



    virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override { TagContainer = GameplayTags; return; }

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GameplayTags")
    FGameplayTagContainer GameplayTags;


Source: http://shootertutorial.com/2016/09/2…-gameplaytags/

But another thing you can do if you don’t want to code is to make your own interface. The interface function would return a gameplay tag container, and in the classes that implements the interface, you provide the function with the gameplay tag container variable.