Hi, I’m working on a boss sequence for a demo where the player gets trapped in the middle of a bridge. To do this, I’m using a dedicated BP for the “boss start,” which contains a collision box used to make two walls/tails on each side of the bridge visible and activate their collision.
Once the exits are blocked, obstacles or attacks will come from the left and right sides (these are the boss’s tails). I haven’t been able to make the object shown in the image (wave_attack, which uses a simple Interp To Movement) spawn from either of the tails. Currently, the wave_attack spawns based on the position of the central collision box in the middle of the arena.
The problem:
I’ve tried various Add and Multiply nodes, but I can’t get the spawn origin to rotate properly. What kind of solution could I try?
I’d totally change the structure of how you are going about this. Since these are unique features for this particular level, I’d be utilizing the level blueprint to control the logic and execution flow. This makes it easier to reference specific actors/objects in the level, rather than having to create those references and possibly even have to cast to the blueprint class (this can create a large reference chain which isn’t good).
As for the actual projectile/attack, I’d have a blueprint class for that, which carries the logic needed for the attack including moving in the appropriate relative direction. Then the level blueprint would spawn the attack at a given location, and you’d just need to make sure the spawn rotation is correct, for it to move in the correct direction.
Perfect, I get what you’re saying and it feels like a whole new range of options just opened up.
Please help me understand a bit more — I migrated most of the logic to the Level BP, but I’m still not sure how to avoid using Cast to BP_Player. Also, I noticed that some references still don’t work, even though the actor is placed in the level.
Should I be doing this differently? Would it be better to separate the three meshes (the box collision and the two tails) out of the Boss Start BP?
Also ¿should i add sequence here for the boss arena?
Yeah, I would keep the tails and collision separate, particularly because you can reference each of those individually as needed in the level blueprint. I wouldn’t have an individual class created exclusively for level props - especially if you aren’t going to reuse those assets in another level.
There are good ways to avoid having to cast to the player, but it generally is not a problem if the player class is likely to be loaded/spawned all the time anyway. The whole idea of keeping reference chains in check is to keep unnecessary loading to a minimum. For instance, if you had class A casting to class B, if class A ever gets loaded, it would also have to load class B. This isn’t as much of a problem if class B is already loaded, but generally it’s best to keep these minimized.
Few good ways to do it:
Blueprint Interfaces: This allows you (as long as you have some reference to the actor during runtime) to send messages to another class - if the class implements the interface, then it will receive the message and call the associated event. This is best thought of as the player has an “Interact” input and multiple different actors can respond to that same interaction (like a door will open and a light will turn on).
C++: If you are able to write code, this is definitely the best way. There are no reference chains, and it is the fast way to do it.
Game State: In your game state class, at begin play you can set a reference to the player to a variable, that all classes would then be able to access (via Get Game State node → Cast to Game State class → Get reference variable).
For classes that I don’t create a C++ class for, I tend to utilize 2 and 3 (set the reference in C++, for the Game State class), otherwise I have reference variables that are set in C++, which then can be accessed in my blueprint classes that inherit from those classes.
As for references that don’t work, you need to make sure two things:
The actor is actually spawned in the game world.
That the reference variable is set with the specific spawned actor reference.
So, in the level blueprint, if you’ve created a variable for the player class, you need to cast to the player and set that reference to the variable, before you can use it. Otherwise, it’ll be null or worse, point to some other memory that will crash the game if accessed (why it’s good practice to check if references are valid before using them).
As for sequences, if you want an animation to play initially, sequences are the way to go.
Alright, for future reference: yes, you do need to handle this at the Level BP level — and you can even work with object pools to more easily reference spawns.
We didn’t have time to implement the full setup, but this is definitely the right path.
Here’s the workaround solution we used: inside the “Boss Start BP” itself, we added an Arrow Component and a Scene Capture to give us direction. Then we configured the spawn to use that point as a reference. By adjusting the position using Subtract nodes, we managed to get it working.