UMG Tutorial-Generating Experience After Hitting Any Static Mesh

Howdy there!

I followed the UMG Tutorial that can be found at the below link but I’m having an issue with the experience bar.

Everything works great but I seem to generate experience whenever ANY static mesh is hit and not just the Cubes like the tutorial says. I pinpointed the problem but being fairly new to UE4, I’m a little lost on how to generate EXP only when certain items are hit.

My first idea was to branch off the ‘Cast to MyCharacter’ node and create a true false statement but when using the ‘Actor Equal’ node it doesn’t seem to be what I’m looking for. I tried creating a new ‘Actor Variable’ as well but I got lost after making it haha. Does anyone have any ideas on how to get that part working?

Thanks guys!

Hello,
You need to specify that experience is won only when you hit this type of mesh. To do that at the output of your hit, drag a wire “cast to” from other actor and select your experience giver blueprint, or from other component and select the component (which give you the possibility to have a lot of different meshes all surrounded by a sphere and checking sphere component for example.)

I’m trying to make sure I get as little help as possible so I can learn this stuff but is this on the right path of what you were explaining? Its obviously not complete yet but I wanted to be sure I was starting it off correctly.

&stc=1

Yes, you cast to the mesh concerned by leveling system, if true then you add experience, if cast failed you don’t, in both cases you link to explosion / particle / destroy actor.

I think that’s where I’m getting lost. When I pull the Cast To StaticMeshActor I’m not too sure how to specify the specific Static Mesh I want. I tried using the ‘Get’ and ‘Set’ nodes but even the ‘Set’ node wouldn’t let me pick a static mesh. Unless I’m missing something?

I take that back, I figured it out :smiley:
Here is what I did in case there is any feedback or advice. I created a new Static Mesh Component and assigned a wooden crate as the mesh. I copied the Experience Giving nodes over to the newly created SMC and removed those same nodes from the projectile Blueprint where everything was originally. I created a ‘OnComponentHit’ node and connected it to the ‘Cast To MyCharacter’ node and now everything works like I wanted it to. Nothing else generates EXP unless I hit the wooden crate static mesh.

Couldn’t have figured it out without you, Fen. Thank you! But please feel free to tell me if I didn’t get what you were explaining. I love knowing all the different ways to do stuff haha.

You made it working ! Gratz ! ^^ There are two ways to do it, or in the hitter, you use the event hit (or related) and do a “cast to” name of the hitted (not only staticmesh but Bp_xpstuff), or as you did in the hitted which “cast to” the hittter. I prefer the first one because you can use the same for different items and different event on hit in same event and you don’t have to do a new one in each new hitted blueprint.
And i love discovering too, this is most interesting part of the engine ^^

Would you mind explaining how you do a “Cast To” the hitted like you prefer? That’s still the part I’m having an issue understanding. Anytime I pull off the My Component, Other, or Other Component pins I can do a “Cast To” but nothing to a specific item. Like I can pull off the My Component pin and do a Cast To StaticMeshComponent but I don’t know how to reference a specific component from there.

Here’s an example of what I’m talking about but have no idea what to do from there because I don’t see any options to select a mesh:

Here is an example : First output is my comp which is the component of the hitter (the sphere around the mesh in the projectile), then there is other actor , if you name all your blueprints Bp_ as it is recommended to do then you can do a “cast to bp” with context sensitive checked and you can see all your blueprints. Then there is other component and again, with context sensitive checked you have all the components ready to use.
558c64323fc5ec91986a0a5968f6b5af57a9d2ff.jpeg

Ooooooohhhhhhhhhh! That makes PERFECT sense now. Makes everything so much easier because I don’t have to put Experience Getting code into each blueprint. I can just keep pulling off the pins and there is no going into each individual blueprint :smiley: That’s the part I miss understood; turning everything into Bp_ to pull it up in the search menu.

Fen, you rock my good sir. Thank you for explaining that because now its less time spent copying and pasting code. But the best part is I know both ways now; knowledge is power >:D