Download

Ray Casting Returns on Certain Actor Hit

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html

I’ve created a working Ray Casting based off this tutorial and it is working great. I have also created an outline around a wall object that triggers when the ray cast hits it, also works. My problem is that I can not figure out how to make the outline turn off when the ray cast has ended on the wall. Basically when you look at the wall it highlights, and when you turn away it the highlight turns off. Should I use a branch? While Loop? I am uncertain on what the next step is. Below is a screenshot.

http://img.photobucket.com/albums/v72/Teriander/Cast_Screenshot_001.jpg

A small retriggerable delay after you set Custom depth that resets it to zero should work.
Problem: if you turn too fast to a different wall it wont reset the first one.

Is that the only way? Because I will want it to be sure to reset the first one. For some reason I couldn’t get it to work with a mouse over event.

I just realisied that it wont work that easy cuz the delay is always retriggering
Im setting it up inside my project. I will let you know once its done ; )

edit:
this works for me
(ignore the custom event. I do the Line trace inside another BP)
40891b098448d267b7222f8622134497ae7cdc6b.png

Question, is the event on your actor (such as your wall) or FPS Character blueprint?

its from inside an ActorComponent of my Character BP. But thats just a design choice of my project :wink:

Another Image without the Event
depth.PNG

Hmm, I am unable to connect to my variable that references my wall actor with a node from “Hit Component” into my variable (WallEntry). In your case it looks like you named your variable to reference your wall as “Component”.

The error message I get when I try to connect mine is - “Primitive Component is not Compatible with Wall_Wall_Entry_Blueprint Reference”. Although my variable is pointed straight to the Wall_Wall_Entry_Blueprint as a reference. Here is a screenshot of my Wall_Wall_Entry_Blueprint and my First Person Camera Blueprint.

http://img.photobucket.com/albums/v72/Teriander/Cast_Screenshot_002.jpg

http://img.photobucket.com/albums/v72/Teriander/Cast_Screenshot_003.jpg

just change the variable type to Primitive Component Reference :wink:

But converting it to a Primitive Component makes the reference to my Wall_Entry_Blueprint break. How do I reference the Wall_Entry_Blueprint now?

Ok I assumed you needed to set custom depth to all kind of Meshes. But if you just need it for your Wall_Entry BP try this

depth2.PNG

edit: sorry for the small resolution. Same setup. Just add a cast to your BP. Now you can connect your variable

Thanks for setting this up on your end. Really appreciate this! I have a question. The variable you have called “Test (something can’t read it)”, is that variable still connected to a Primitive Component reference or is the variable directly linking to your Object Type > Test (something) > Reference? Screen shot below:

http://img.photobucket.com/albums/v72/Teriander/2015-12-06_Casting_001.jpg

Its a direct reference to the BP (which you call Wall_Wall_Entry) that the line trace hits.
Forget about what I said about changing it to PrimitiveComponent…

this should make it clear. I renamed everything to match your setup.
a059ca8d97a88b77ea5f4427d85370f5acc08378.png

So what does this nonsense actually do? ^^
-Every Tick you make a line trace that hits the Actor in front of you. You cast to your Wall_Wall_Entry BP. This is like the first check to see if the hit actor is a "Wall_Wall_Entry BP. If its not it will always be CastFailed.
-When its succesfull you set the outline.
-First Branch checks if the Variable “WallEntry” is valid (if it was ever set). This prevents an error that occurs when you first look at your Wall
-Second Branch checks if “WallEntry” is the same as the tick before. If true, fine. else you disable the Outline to the old Wall that is still referenced by the variable.
-at last you reference the new Wall.

(also for the record: you can still use SetCustomDepthStencilValue.)*

For some reason when I move the blue node from “Cast to Wall_Wall_Entry” into “SET Wall_Entry” variable, I am still getting the error - “Primitive Component is not Compatible with Wall_Wall_Entry_Blueprint Reference”. So I am unable to attach the blue node into this. My post #7 Has a screenshot of my Wall_Wall_Entry blueprint. It appears correct to me, but not sure why I continue to get the error.

Thats because your variable type is set to “PrimitiveComponent”. You cant connect different variable types with each other. You have to revert it back to what it was namely → “Wall Wall Entry”
Or just delete it and drag the blue node somewhere and promote it to a variable…

Also you might wanna watch this Tutorial Series to better understand how variables work.
https://youtube.com/watch?v=zaVY5A0hqiI

Yes, I still had it set to “PrimitiveComponent”. Sorry about that, I thought I had changed it. Thanks for the link to the variable tutorials. I had an understanding of variables prior, I just missed the PrimitiveComponent change. I’ll test this out tonight and let you know the results! Thanks again!

Ok, so I have added your script, and it works. Partially. When I look at the wall it turns red, when I look away, it says red. I’ve put details in my screenshots below. I have also added a modification that made it work, but I get an error message and not sure why. Any suggestions?

http://img.photobucket.com/albums/v72/Teriander/2015-12-07_Casting_002.jpg

http://img.photobucket.com/albums/v72/Teriander/2015-12-07_Casting_003.jpg

http://img.photobucket.com/albums/v72/Teriander/2015-12-07_Casting_004.jpg

http://img.photobucket.com/albums/v72/Teriander/2015-12-07_Casting_001.jpg

Oh I see my mistake now. Should have tested it after altering…Ups
Just add another Branch (like the first one) before your modification so it deactivates CustomDepth only if false.
I think “isValid” could be used too instead of a Branch.

Everything is working now! I used a isValid because I never used it before, and it works great! Thanks again for your support. I have learned much from you!

Hey Minaosis, question. I’m trying to set this up to work on multiple objects, for example, when you look at the floor it outlines, the ceiling, etc. But I think my camera blueprint will get cluttered if I had a 20 cast from the trace. So Im thinking I either need to move some of this script into a Construction Script and have my Trace execute based on the object name it hits. Or I need to setup a function. What do you suggest?

Dont really know what youre talking about

But

Easiest way to outline multible objects with the setup you already have is to make a Parent Class for all BPs you need.
I will give you an explanation how to do that. (Tip: always make a copy of your project before doing what a stranger tells you ^^)

  1. Make a new Blueprint Actor. Call it Parent_Something. Add a Static Mesh and a Box Collision (rename it Trigger)

  2. Do the following in every BP you want outlined:
    In the upper Left corner click File->Reparent Blueprint. Select the new Parent_something BP you made. (You will see the Static Mesh and the Box collision in every Child now). Set the inherited Mesh, and size the Trigger to what it should be. Delete the old (not inherited) ones.

  3. Now that every Bp has the same Parent, you have to change the Script that I showed you: Replace the “Wall wall entry Cast” with a Parent_Something Cast. Rename the “WallEntry” Variable to Something like “CurrentOutline” and change its type to Parent_Something. Connect the Broken links again.

It should work now with multible objects. Of course this broke all the connections you had with the “WallEntryVariable”. But since I dont know what else you’re using it for I cant help you.
Also whats important: If you had any Script inside your Wall, Ceiling, Floor Bps that happens in everyone, move it to the Parent. Leave it only there if its very specific.

If you need further help, add me on Skype -> Minaosis. Dont get me wrong, I like to help. Its easy for me to point you in the right direction and give you examples. But you have to comprehend those examples und adjust them to your needs by yourself.