How to find a specific set of objects in an array from a line trace ?

hi , im making a game where you can possess multiple different objects each of which have their own uses, so when i line trace and a hit is detected i want it to reference the array and see if the hit object is within the array, but it always returns false ?? i feel like theres something im missing

Hey @cptfunjuice! Welcome to the forums!

Are you wanting to return the first object?

You might want to do a “Line trace by channel” which will return the first thing hit, and then if you find something of the type you’re looking for it outputs that single object! That might be more of what you’re looking for.

Also I don’t know what’s in the possessable array, but are they physics bodies? Because a physics body is typically a component. Maybe try out hit hit component! :slight_smile:

im looking to cast a line trace out by pressing e, hit an object, check if that object is a “possessable” object (in that possession is a mechanic like mario odyssey or ctrl alt ego) and then to run the possess function where i spawn a character controlled version of that character in its place. hope this clarifies it more and if you need any screenshots or more infor lmk :slight_smile:

better to use an interface, you can check if the actor implements interface which will be more modular in future

1 Like

Yes, you will want to use “Line Trace By Channel” and then take the Out Actor, do an “IsValid?” Macro check (the gray one) and if they all have the same parent you can do an == class node, and then possess from there! :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.