On Component Begin Overlap (Box Collision) ?

Hey, I’m trying out Box Collision in Blueprint for the first time, but I’m a bit confused on how this works.

My goals is to spawn Cube when the character enters the Box Collision and Destroy the cube when the character leaves the Box Collision.

Randomly I found the “On Component Begin Overlap (Box Collision)” node , which spawns the cube on begin overlap. Now I only need to destroy the cube when the character leaves the Box Collision

I have 2 problems:

  1. If I search for “On Component Begin Overlap (Box Collision)” is can’t find it in the list (with and without “Contest Sensitive” enabled)
  2. I can’t find the "On Component End Overlap (Box Collision)

I feel like its really tricky in Unreal to find nodes and how can I make this Blueprint work?

P.S. I already found a method on Box Collision joint to the Character, but I prefer to have a Box Collision joint to the object actor.

I appreciate any help i can get :sweat:

1 Like

Right click on the collision box

image

Then you can

cube

You can’t cast to the player actor, because we need to know what kind of actor it is, so we cast to the actual player.

To be more general, you could say

image

I spawned the cube in front of the BP, otherwise you’ll just get stuck on its collision.

6 Likes

Thank you for the great explanation, I really like how you use a setter and getter, but I’m keep getting a runtime error when I leave the Collision Box:

“Blueprint Runtime Error: “Attempted to access Cube_C_5 via property NewVar_0, but Cube_C_5 is pending kill”. Blueprint: 10_Trigger_Box Function: Execute Ubergraph 10 Trigger Box Graph: EventGraph Node: DestroyActor”

My steps were:

  1. Right click the SpawnActor Cube Return Value (Output) and Promote to Variable
  2. I dragged to newly greated variable into the Event Graph and selected Get
  3. I bind the getter to the DestroyActor Target (Input)

I checked online, and I believe program thinks the getter is set to a null object? I repeated the steps a few times, thinking it had to do something with naming the variable, but with no luck.

1 Like

It’s your variable NewVar_0 that’s causing the problem. You need to set that ( or get rid of it ).

Another possibility, is the actor isn’t spawning.

Reason for that may be

  1. It can’t because you’re in the way ( that’s why I moved the spawn point ).

  2. It’s not a well-formed blueprint. Is it even a blueprint? What is it? :slight_smile:

2 Likes

Again thank you for your reply. I removed NewVar_0, but I had no success. I rebuild the Blueprint from scratch based on your Event Graph (as close as possible) and Rebuild the level, just to in case. At the moment I walk out of the Box Collision I get the same looking error:

LogScript: Warning: Accessed None trying to read property Cube_Ref
    10_Trigger_Box_C /Game/FirstPersonBP/Maps/UEDPIE_0_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.10_Trigger_Box_C_1
    Function /Game/Cookbook/10_Trigger_Box.10_Trigger_Box_C:ExecuteUbergraph_10_Trigger_Box:0015
PIE: Error: Blueprint Runtime Error: "Accessed None trying to read property Cube_Ref". Blueprint:  10_Trigger_Box Function:  Execute Ubergraph 10 Trigger Box Graph:  EventGraph Node:  DestroyActor
LogScript: Warning: Accessed None trying to read property Cube_Ref
    10_Trigger_Box_C /Game/FirstPersonBP/Maps/UEDPIE_0_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.10_Trigger_Box_C_1
    Function /Game/Cookbook/10_Trigger_Box.10_Trigger_Box_C:ExecuteUbergraph_10_Trigger_Box:0015
PIE: Error: Blueprint Runtime Error: "Accessed None trying to read property Cube_Ref". Blueprint:  10_Trigger_Box Function:  Execute Ubergraph 10 Trigger Box Graph:  EventGraph Node:  DestroyActor
LogScript: Warning: Accessed None trying to read property Cube_Ref
    10_Trigger_Box_C /Game/FirstPersonBP/Maps/UEDPIE_0_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.10_Trigger_Box_C_1
    Function /Game/Cookbook/10_Trigger_Box.10_Trigger_Box_C:ExecuteUbergraph_10_Trigger_Box:0015
PIE: Error: Blueprint Runtime Error: "Accessed None trying to read property Cube_Ref". Blueprint:  10_Trigger_Box Function:  Execute Ubergraph 10 Trigger Box Graph:  EventGraph Node:  DestroyActor

Do you see the cube appear?

Can you show what’s in the cube BP?

I’m also wondering about this strange icon

image

What is the parent type of this BP?

1 Like

Yes the Cube appears when I walk into to Collision Box, and the error appears when I walk out of the box, whit the cube remaining. The My_cube_BP is just is Static Cube.

What is the parent type of the spawning BP?

1 Like

If you mean the reference class: “My_Cube_BP”, its a Parent Class: Actor Blueprint

Nope the one with the code in :slight_smile:

If I make a new actor BP, I end up with

image

I’m wondering how you made the main BP

One last thing, I’m checking you’re not passing through the collision box at great speed? Like entering and leaving in the same frame.

1 Like

I’m not sure how to answer that, I just follow standard procedure, but I just found a hint. As I walk into the Collision Box, 4 Boxes spawn, when I move out one gets removed :open_mouth:
Why 4 boxes I wonder?

Ah, we’re getting to the root of it… :slight_smile:

I wonder if you’ve tweaked some settings in the collision.

Instead of using ‘on component …’, try changing those two nodes to ‘begin overlap’ and ‘end overlap’

image

1 Like

If I replace the “On Component Begin Over (Box Collision)” with a “Event ActorBeginOver”, I believe in theory, the node is not joint with the Box Collision Object, in practice I get a error:

Infinite loop detected. Blueprint: 10_Box_Collision_2 Function: Event ActorBeginOverlap Call Stack: Show

But if we go back to the previous example. When I walk into the wall of the Collision Box only 1 cube spawns, but if I go further more cubes spawn. Its seems “On Component Begin Over (Box Collision)” activity is handled by the Box Collision volume, not the boundary?

I just ran this code, it’s fine. It will stop you getting 4 boxes

Under certain situations, that component collision stuff is a bit flakey. Two main solutions are

  1. Use do once nodes

  2. Use the above.

3 Likes

OMG!!! It finally works, I’m so happy right now. I want to thank you properly ClockworkOcean, for helping me along the way. I’ve learned a lot, thank you! :clap: :clap: :clap: :clap: :clap: :clap: :clap:

1 Like

Ha! :smiley:

1 Like

The reason why it spawns 4 cubes, is because box overlaps not you, but your character components. Your mesh, your collision capsule and so on…

1 Like

That makes a lot of sense, good to know :open_mouth:

Hmm… not for me… Presumably we both have the same first person character…

Have you made any changes to the character?
Because I don’t see any other reason for Begin Overlap fire 4 times.