I’m a beginner using UE4 and need help getting the correct overlapping character from the spawned characters to perform a task. I know this is broken and have an idea of how to fix it, but I don’t have the UE knowledge to do what’s in my head.
The Spawner BP creates a few characters every 4 seconds. After the SpawnActor, it incrementally counts. The Spawn ID is a function that is setup in the character BP. I’m using something I found online and it happened to work. So, in the level BP, event ticks calls custom event All Machs which gets all of the characters (Modular Mach). I promoted the Array Element to a variable called Mach Replica. Then I reference Mach Replica in the Overlap setup. I know all of the characters are in the array, but don’t know how to separate them so I can test the overlap individually.
What I’m having trouble with is getting the specific overlapping character in the BeginOverlap/EndOverlap to perform the Do Task 3 event. Right now, pressing the key will perform the animated task to a random character in the array. How do I “extract” the character from the array? Basically, if character_1 overlaps trigger box and key is pressed, perform task to character_1.
Thank you! That got me 90% there. The character overlapping the trigger box now performs the animation needed. However, sometimes it pull in characters that have already passed the trigger box.
The easiest way to decribe my scene would be like watching the Macy’s parade. Characters spawned would be like people walking past the camera in the parade. When they overlap a trigger box, you can press an input key that makes them pause and wave. With the new change, most spawned characters will function properly, but sometimes a character that has already passed the trigger point will perform the input key animation. How would I fix that part?
I removed the custom action with Get All Actors of Class because it wasn’t affecting the scene. I did add a simple text render that simply becomes visible when the characters overlap the trigger box.
There isn’t much else in the level blueprint, but here is the setup in the character blueprint. It’s not very clean, but I wanted to get something working before cleaning it up. On begin play, there is an immediate delay to offset the characters. Then the characters, travel to a destination off screen (Target Initial) and are destroyed after 12 seconds so they don’t pile up.
When the input key is pressed, the DoTask stops the current movement. I’ve alternated between using Stop Movement Immediately and using Disable Movement for this. Step 2 of the Sequence, moves the character to the target (center stage) delays for a few seconds to perform the wave animation, and then continues the to the final target destination. Step 3 of the sequence is performing the wave animation.
I’ve used several alternate ways to move the characters to the target when the input key is pressed. Simple Move to Location, Move Component To, and MoveUpdatedComponet don’t work. I’m pretty sure they don’t work because I’m using a AI Move To in order to direct the characters to the final target.
Task 3 should only happen when the input key is pressed. Currently when the character spawns, it goes to the target destination and the character is destroyed after 12 seconds.
The overlap is in the level blueprint because it was initially easier to setup there. And so now I have the level blueprint talk to the character blueprint to perform task 3. DoTask3 is only triggered when the input key is pressed in the level blueprint.
Long story short, I tested the functionality in the level blueprint first because it was easy to get references to the target points, trigger boxes, etc. I’ve been trying to put some of the functionality in the character BP and using custom events instead because people have told me it’s more efficient.
Thanks! That makes a lot of sense about level BP vs character BP.
As far as the scene setup, I really don’t know. My initial guess was that when a spawned character overlapped the trigger box and the input key was pressed to animate the character, it would cache the info. When the input key was pressed again later, any character that previously performed the wave animation would repeat the character animation. This happens a lot when the input key is pressed multiple times but there are times when a random character will perform the animation along with the character overlapping the trigger box.
This is why I was curious if I could assign each spawned character an ID and then use that in the overlapping nodes to make sure that it only the specific spawned character performs the animation. I want to be able to add a 2nd trigger box overlap animation for the characters but need to get the 1st one working properly. Thanks again for your so far.
I disconnected all of the delays yesterday and it still doesn’t work properly. It will animate the character overlapping the trigger box, but will still grab another random character that has passed the overlapping areas. By any chance is there an issue with Get Player Controller in the Enable and Disable Input nodes because these are spawned actors instead of the third person controlled character?
Yes. I checked the Input in the character BP and Auto Receive Input is set to Disabled. Is there anything else in the character BP that I can check for? It seems in UE that one checkbox can make or break the scene. Since I followed different tutorials to get to this point, I might have changed something along the way.
Here is an image of the Print Strings. It seems like the Begin Overlap (Press_C) and End Overlap (MissedIt) are working. The 4 is a Print String that is counting how many characters have been spawned.
I guess I’m still confused why if the 4th spawned character overlaps the trigger box and the input key is pressed, both the 4th character and the 1st character both execute the animation, even though the 1st character passed the trigger box several seconds ago.
I feel like I’m getting close but missing something simple.
I ran into this error when trying to plug the Other Actor into the Do Task 3 which is in the character BP. I think the error makes sense because the characters are spawned and have to be cast to Modular Mach first.
After I plugged things back up the way they were, I did a test by placing the characters directly in the scene and getting rid of the spawner. The three characters in the scene are having the issue with inheriting each other’s animations and a character that has passed the trigger box performs the animation. So my guess is there is something wrong with the character BP. If you have any suggestions, I’ll take them