I wish we had an easier way of changing variables between different BP classes. I just need to define and change global variables but I don’t understand how to do it. I don’t understand the interface tutorials and I don’t understand casting. Can anyone break it down barney style for dummies like me?
How can I define and get/set global variables? How can I define and set and get variables within a scope? How do the terms casting and interfacing relate to scope? My background is in lower level code and I don’t understand these terms or functions and how to use them effectively.
I would suggest not using them if you can though, unless they truly need to be, and are global.
Here’s how casting works: When you successfully cast to a class, you have complete access to all the variables inside said class. To successfully cast, you need a valid reference. There are a millions ways to get a valid ref. I’ll list a few.
If you only plan to have one instance of a class in your world, you can use this method:
If you want to chop a tree and reduce the “remaining wood” the tree has, you can line trace to get the reference. The cast will fail if you don’t successful trace to the tree actor, which would give you an invalid ref:
You can get a reference by overlapping. In this case, the players overlaps a collision box inside CastActor, and CastActor casts to the player to give it a speed boost: