Trace problem

I have an item inside a closet. I want the trace to trigger on the item only if the closet is open, but since the closet itself is also using the trace to outline it how should I go about doing this? I am going to have the same item in other places also so I cannot simply use a bool to check if the closet is open or not. I hope there is a way to stop the trace if it hits the closet so it doesn’t go through and hit the object.

If you have a blueprint for this closet, and you will be placing the blueprint in multiple places, then you CAN have the Boolean method work. And why don’t you just make it so that the closet blocks the trace?

[=;280710]
If you have a blueprint for this closet, and you will be placing the blueprint in multiple places, then you CAN have the Boolean method work. And why don’t you just make it so that the closet blocks the trace?
[/]

How can I make it so that the closet blocks the trace?

well it should be blocked by any collision you may have on it.

Even tough it’s set to block traces ( which is how the event gets triggered to outline the mesh) it passes through and hits the object inside ( and triggers that one also).

Well, here’s a solution: If you have a blueprint for each closet, just use a Boolean. If you have 1 blueprint for many closets, use an array of Booleans.

I would much rather have the traces being blocked, is that possible?

Hi Robbie222,

Are you doing a single line trace by channel or a single line trace for objects? Can you show me a screenshot of your specific trace setup?

[= ;280941]
Hi Robbie222,

Are you doing a single line trace by channel or a single line trace for objects? Can you show me a screenshot of your specific trace setup?
[/]

Hi ,

Here you go:

l.e - just noticed I had the cast start and end reversed from camera. Fixed that now but still doesn’t change the fact that the traces don’t stop when they collide with the closet.

Also any ideea why casting to this BP always fails?

For the casting error, is your player controller of type skeleton? If not, then it will always fail because you are casting the player controller to a blueprint type that it is not. For your trace, the only object type it is tracing for is “vehicle”, so unless your cabinet is a vehicle it will ignore collision with the cabinet. What I would do is set the cabinet to static or dynamic, and add to your object array objects of the same type (static/dynamic). Then, drag off of your return value and do a branch that checks to see if the return value == the object type you provided, if so, do nothing, if not, then it should be the object type you are actually looking for (in this case, vehicle. On a side note, I would create a custom object type for the items you’re looking for, just in case you want to use vehicles in your game in the future). Please let me know if you need any further assistance or if this doesn’t work, I’ll be happy to take another look when I get a chance.

In the casting error I am trying to get a reference of the boolean inside the skeleton bp ( which has a static mesh component). I am trying to do this from the character bp.

As for the trace issue : I’ve used the vehicles collision type because I know for sure I will never have vehicles in the game. When I’ve set the the closet mesh also to vehicle it didn’t trace the object inside through it anymore which is what I wanted. However now something strange happens…after I open the closet and look at the object inside it triggers it, but when I look away it never triggers the “StoppedBeingLookedAt” anymore. I’ve duplicated the object and put it outside the closet and there it works fine.

Cast from first person character to static mesh bp fails, I’ve tried to make a boolean in the FPC that gets set from the static mesh bp through cast…that fails also. What am I doing wrong?

in the case of your boolean, if your cast is set inside of your player blueprint, you need a variable of type skeletal bp, not character bp. What a cast is doing is asking a variable “What are you? Are you this?” If the answer is yes, then it can access variables and functions set within that type of blueprint. If this cast is happening after the trace, you can break the hit result on the trace, then cast “Hit Actor” to skeleton BP. What this will read as is:

I (Character BP) hit an actor, is that actor a skeleton BP?

&stc=1

The above image is from my grappling hook tutorial. The line trace hits an object, and immediately checks to see what type of object that is. Because I have different functionality based on if it hit a pawn or any other object, it only needs to determine if that object is a pawn. If it is, do functionality A, if not, do functionality B. To do that, it has to use a cast to literally ask if the object is the type of object that the cast it tied to. Another example that may be more useful can be seen in the archive link here:

https://forums.unrealengine.com/archive/index.php/t-24967.html