Casting Between Two Class BP

So I’ve been having a lot of trouble getting this working.
I have a desk with two drawers in it. (Each with their own separate BP using a timeline to open and close them)
I have a box collision set up on the front of both drawers.
When the player looks at it they are able to open the drawers and this all works fine.
My issue is when the top drawer is open the player is able to still open the bottom drawer because they are colliding with the bottom drawer through the top one.

Is there a simple thing I’m missing in order to be able to disable the bottom drawers BP when the top drawer is open?

Casting never seems to work for me.

I have this set-up for both drawers and then a simple key event to timeline to open them.
Any help would be greatly appreciated.

From my understanding, you are able to open the top drawer by itself, then are able to open the bottom one after correct?

If so, I would imagine you could use a boolean to check if a drawer is already open. Once one drawer is opened, another can’t be opened till that drawer is closed.

However, if you are opening both at the same time, you could use a flip flop to have it toggle between the two starting with the top drawer.

Im not sure the code you have for detecting which you are looking at, so I can’t suggest anything further than this.

Hope it helps,

Garrett

Hi Garrett, That’s exactly it. I can open the top drawer but I can then interact with the bottom drawer through the top one. I basically used a collider coming from the camera to determine when the collision events occur. I have a variable set up for both the top and bottom drawer when they are open/closed. I want to basically send that info to the bottom drawer and when the top one is open disable the collision for the bottom drawer.

The issue I think I’m having is what to put into the casting node.

I thought this may work but it never goes through the cast node (This is on the top drawers blueprint) I have the tick checking for the status of the top drawer. I then want to send that info to the bottom drawer and disable the collision until the top drawer is closed.

This has been driving me insane haha I’m sure im just missing something here.

Is it important in your setup to have them as collisions? If not then why not make it a button interaction and when the button is pressed you use a line trace to open that drawer? Using a line trace it returns the first hit actor and therefore will never go through the top drawer and open the bottom one. Only way bottom one would open is if you were looking directly at it and pushing the button.

I’ve set everything else up this way. I had trouble with the Set Render Custom Depth node when using line trace from the character. Seems to keep glowing when you move away from the object.

I have it set up so when you collide the object glows and interaction is enabled, and when you look away (not colliding with object) the glowing stops and you can no longer interact. (This has been working a treat until now) Then when you press ‘F’ it opens and closes.

That’s where the issue arises of being able to trigger the bottom drawer.

This video may give you a better idea of what I mean.

Thanks for the suggestions so far guys.

How are your world objects set up?

If both drawers are child objects or referenced somehow by the TeachersDesk object, could you possibly access the TeachersDesk from one of your drawers and from there access the other drawer to disable the collision? Or alternatively, set a boolean on the desk for whether any drawer is currently open, as Gurb suggested, or an integer to keep track of the number of open drawers, and compare against that in your collision check?