I’m trying to test to see if the hit box is inside the array spawning from the player camera when the left mouse button is hit but I don’t know the function that would allow me to do that. What is the missing piece here?
Could you, please, give more info about your problem?
Do you mean that after clicking left mouse button an array of objects spawns at the place the players looks at, there are some object present and you want to know if any element in spawned array intersects that present object?
second one. There is an object and I want to know whether or not the object intersects any point in the array when the button is pressed.
You might be using the term “Array” incorrectly and that is potentially causing some confusion.
To clarify, do you simply want to know if there is an object in an area (for example a box) and you want to know it when the user clicks the left mouse button?
If that is your question, the answer is BoxTraceForObject(s). Matthew Wadstein has an easy to follow video that is still relevant (WTF Is? Box Trace for Objects).
If that is not your question than it might help to break it down a little into smaller parts to understand what you are trying to do. Maybe start at the end and work backwards.
It isn’t working. the objective is to use the left mouse button to cause an object the player is looking at to toggle between two states. I’m able to get it to toggle between states but I can’t get it to determine if I’m looking at it.
On second thought, maybe it would be better to try and create a projectile that toggles the function on the object.
I would definitely not go the projectile route.
Did you look at the tutorial I linked? There is another version of that same explanation for Sphere Trace and Capsule trace that you can use instead. Here is an example of the Sphere Trace that I use (trimmed-up for demonstration here):
In my case this puts the sphere forward by 20000 units and makes the sphere with a 5000 radius. If you set Debug Draw Type to “one frame” you can see the sphere in your game world. You would need to use something else like the root static mesh, some other static mesh or the actor itself in place of my Niagara component that I am using.
Do this on Event Tick and it will reposition every single frame. This gives the first actor hit. If you want all the actors in the sphere then you use the “Multi” version of the same call.
If you need further help on this I suggest posting a screenshot of your code where you are trying to make this call.
I did watch the video but I don’t think it helped. I’m trying to use “damage” to register hit detection but it’s still not working.
Hey.
Can’t really make out what you are doing here. Can you share with better res? :
Also there is nothing plugged in DamagedActor:
In any case, think this might help:
Let me break this down a little so you can see the parts you need to solve. You have three things that really don’t relate to each other directly:
- Activate on Mouse Button - I think you understand this part.
- Find the actor the player is looking at - This is the part you can’t do right now.
- Toggle the state of an actor - Once you have the actor I think you know how to do this part.
So really, you need help only with number 2. What I sent you will accomplish that, but it has to be positioned correctly or it won’t be looking where the player is looking.
You posted the code where you do the trace but it is too hard to read. However I think your problem is that you have the Start and End flipped from what I had.
To be sure you have it correct, you need to change DebugDraw so you can see what your trace sphere looks like.
Like pezzott1 said, if you can post higher quality shots we can see what you have wrong.
Doing funky stuff like using projectiles or damage to “find” something is not the right way to do it. This is. It works. Just be patient and focus on it until you understand it and get it to work. You will get there.
What you are working on now is a fundamental aspect of gameplay. “Finding” actors for different situations is foundational, so spending time to understand it is not time wasted.
I want to get the object to detect the hit from the line trace and do so without blocking the third person pawn as the player will be expected to walk through the object while it’s turned off.
Someone, else said a blueprint interface might help so I’m trying to figure out how that works.
I needed to make the object tangle to the line trace while being intangible to the play by making a target volume within a trigger volume who’s collision is turned off upon entering the trigger area and turned on upon leaving the trigger area, however I discovered that it registers the reappearing target and an object entering it’s space triggering an infinite loop. I’ve tried attaching an “Is Actor Targetbox” to a false branch but that did nothing.
By creating a Blueprint interface I was able to send a message through the interface to activate the mode switch upon collision. I’m going to mark it as solved since the main question was answered however now I need to find out how to make a trigger box that will block my line trace but allow me to walk through it like a ghost.