How to attach objects to enumeration?


I have been trying to “get comfortable” with the blueprint system (the concept isn’t totally clear yet. I’m used to objects, scripts, prefabs, but this is something totally new :P) and was learning different nodes, more recently Single Line Trace for Objects. The object type want’s to be an enum-array, so I made one, but I have yet to figure out how do you mark other blueprints as, for instance, “shootable”.

Hoping for answers, -DoctorPC

In project settings, go into the collision menu. This is how you make new object and trace channels so you can tailor what collides with what. After you make them, they are automatically assigned to every object so you have to go into all your blueprints and update them.

As for the enum array, I just use trace by channel which doesn’t require an array of objects, just the proper trace channel.

sounds legit, I’ll give it a shot :slight_smile:

Tried it, and it works, or well, it should work, but yet it doesn’t.
Something in my blueprint causes every shot be counted as miss, I would really love if you took a look at it:

firing 1

firing 2


Thanks, -DoctorPC

What is New Var 1 set to? That is probably your problem. Instead of tracing for objects, use the Trace by Channel node. Then you can just set your Channel to Visibility so you can make sure everything works before testing out new channel and object settings.

Also, use the Draw Debug on the trace node. It will show a red line when you shoot, and whatever it hits will have a little red box to let you know it hit.

Also, print off the hit actor so you can be sure what is being hit so you can be sure it isn’t just a failed cast or something.

New var 1 = Target. It’s just a way of telling make array which object from the enum to choose.

I now swapped to trace by channel, and it looks like this:

the outcome is identical, and the object name seems to not print.
(other areas are as they were)

Some odd effect, or visual artifacts:
when moving the screen around a light source quickly enough, the gun seems to create “ghosts” of itself, Those faded pistols can not be seen in screenshots, though :confused:

So your red debug trace is showing little red box signifying a hit on the object you are aiming at?

yes, or well, approximately where I’m aiming at. It doesn’t seem to be always the same, sometimes it goes 200 pixels to the right, sometimes 500 pixels. It’s being a bit weird.

I finally got it working! Thank you so much, here, have some extremely well earned karma :3

Okay, did more investigation about the off set. Looks like it goes to the left of the center of the screen, and the further away I’m from the object, the more to the left the ray hits, which is quite peculiar. Is there any reason for this to happen?

I would look at whatever method you are using to set your vectors for the trace. Not sure what else could cause that.

Maybe coordinates of the camera somehow aren’t “in the middle of the screen, but further back”?

I actually had that problem once. My camera was offset from the player pawn somehow and it was causing me all kinds of collision problems. Took days to figure out.

well, could you possibly explain how did you fix it in the end? :slight_smile:

Basically just brought the camera to the character capsule.

It depends on how you have your character setup. I don’t actually have a character, more like a camera floating in the sky that is attached to a character capsule for the sake of movement inputs.

Do you have a blueprint assigned as your primary pawn in game mode? This is where I have my character setup. In the components view of that blueprint, it shows my camera and the capsule, and I just made sure they were on top of each other with rotation properly aligned.

It might be a little more complicated if you are third person… First person could be near the same.

For my trace anyway, I Get Player Controller, Convert Mouse Location to World Space, and Feed World Location into Start(on Line Trace), and then add World Lcoation and World Direction plus some extra length to feed into End(on Line Trace).

I in the other hand have the world loaction of the camera, add 32000 in it’s each coordinate, and do math "CamLoc*Forward vector of CamRot) which I get the end point from. I go see the rotations :slight_smile: