Hey guys. In my game I’m working on, there is a mask that you are able to take off and put on at any given time, AFTER you have collected it. Currently, I have it set up in the FirstPersonCharacter BP so that whenever you press a button, it’ll put the mask on. Now that I have that working, I actually put the mask inside the map and set it up so that you can pick it up. Now, I need to make it so that you CANNOT use the mask UNTIL you’ve picked it up. Currently, you can put on the mask at any given time, but that’s not what I want. How can I achieve this?
You could just use a simple boolean variable that you set after picking it up.
I tried that, but I’m not sure how exactly to do it. Since the mask is inside the level and I’m not using the Level BP to take the mask on/put it off. Also, I AM using the Level BP for the picking up of items. I guess I need to set the boolean from inside of the Level BP then, but I don’t know how…?
The mask is an actor in the level before you pick it up right? Do a line trace to the mask, and, for example, if you hit “f” you can determine whether it’s a mask or not, and if so, destroy the mask actor, and set the bool to true
That’s actually EXACTLY what I have so far Glad to see that I’m doing that part correctly, at least. The thing is, I don’t know where to create the bool or how to access it from a different BP. I’m assuming that I need to access the bool from my FirstPersonCharacter BP, because that’s where I’m putting the mask on/off and where I’ll be checking if it’s been picked up or not. Do I create the bool in the FirstPersonCharacter BP and then set it from the Level Blueprint, or do I create it in the Level Blueprint and get it from there? Sorry if my question is not clear.
I would do it on the character BP. How you set it would depend on how you are picking the item up.
For example, if the line trace event happens in your player controller BP, you could cast to your player character BP and set the bool right after you’ve confirmed you’ve “seen” a mask.
pickup keybind -> line trace -> hit mask = true -> cast to playerBP -> set bool
Ah, okay. It actually happens in the Level Blueprint. I’m new to casting, so how exactly would I go about casting to Player BP and getting my Has Mask var. from there? Thanks a ton for your help so far.
You can “Get All Actors of Class”, choose playerBP, get first index, and use that as a reference to cast. However if this is multiplayer I really wouldn’t suggest doing this on the level blueprint…
Why not do it from the character? Or controller?
It is not multiplayer. The reason I did it from the Level BP is so that I could easily check what was hit and check if it was the mask from the level. I wasn’t sure how to get an actor from the level inside the Character BP. And okay, thanks!
Oh… That’s what traces are for. I thought you said you were using them?
This is in my playerBP:
If I look at the mask, hit the key bound to the event… It will trace from my camera to whatever I am facing… If it’s a mask, it’ll set the bool.
I apologize, I must not have been clear. Yes, I am using that. I just don’t know how to check if it’s hitting the mask when it’s in the Character BP. Since I was checking in the Level BP, I was able to just get a quick reference to the mask actor from in the level and see if the Hit Actor was = to the mask.
Also, what exactly is the Actor Has Tag doing? Is there a way to set the tag on a specific actor?
EDIT: Just figured it out. You… are a beautiful person. Thanks so much for the help! Also, how can I do this for several different objects in my game? So I can interact with different things rather than just the mask. Is there a way to check for different tags and have different results for each one? Obviously I’m fairly new to Unreal, so I’m not too great with this stuff yet.
Well, as an example, if you were to have hundreds of items… Let’s say, all kinds of weapons, potions, and gear. You’d make a Parent_BP, and make children of that BP. Then, you can just tag the parent as “Item”, and if you trace to an “Item”, you can cast to the parents BP and get all the info you want from the child, like whether it’s a weapon, potion, etc… and of course every other attribute it has. That way, you’d have support for unlimited items using only a single tag.
How exactly would I make a Parent_BP? Is it just a regular BP named Parent_BP? What do you mean by make children of that BP? Do you mean create a BP for each item and make that a child of the parent BP? Sorry, I’m really new, again.
Make a BP as you normally would, and name it whatever you like. Now right click on it and choose “make child BP”… And now you have a child BP that inherits the properties of the parent. You could have all kinds of properties like mesh, weight, damage, price, etc etc… And the best part is you can access these variables by casting to the parent.
Ok, I see. So do I make a child BP for each item, or what?
Yep, same thing as making a new BP for each item… The thing about this is the children will have all the necessary variables to make an item inherited from the parent. With my system I make a completely unique item in seconds.
Make child -> Name it -> open it up -> set variables
Heh, okay, thanks. Sorry for all the questions, but I think I’ve almost got it. I don’t exactly understand how to use the Parent BP/Child BP setup though. Could you tell me how to, for example, use the Child BP to set up an actor that prints a string when you interact with it (pressing E and hitting it with the line trace)?
Make parent, give it a string variable and a tag -> Make two children, and give each child a different string for testing purposes ->
Make line trace -> if we hit actor with “tag” -> cast to PARENT BP -> grab string variable -> print
You’ll see both children will print their own results