How to use SingleLineTrace to collide with other characters?

I have followed the principles of Unreal Tutorial 54 (Blueprint Quickshot 8 - Adding Interaction)

The traces triggered by Single Line Trace By Channel seem to only collide with simple objects (like boxes converted to blueprints).

In my game, I have centralized the input controls by moving them into their own Player Controller Blueprint – so they don’t live in the MyCharacter Blueprints used in the tutorials. And they work fine with the simple interaction examples using an Blueprint Interface event.

I have created several different characters in my game that you can walk up to and the idea is when you interact with them, you can take control of them… much like a character getting into a car.

However the single line channel traces don’t collide with anything that is a “Character” – not the mesh, not the capsule, it just goes right through it. So is there something I’m missing to connect the dots here?

Here is a snippet of my PlayerController (used by all characters). Currently assuming single player so using Index 0 everywhere. This is what triggers the raycast and subsequent OnInteract event. Now this new variation actually does mostly what I want. I switched from SingleLineTraceByChannel to SingleLineTraceByObject, created a ObjectType array containing just Pawn, and rejecting my own pawn – otherwise it was triggering myself each time. The self check fails because it’s a PlayerController, not a pawn. Also note, this no longer works for the non-pawn objects anymore like the interactive chairs etc. Probably need to set more object types in array.

Here’s the target character hookup (all the characters are setup the same way – and based on the 3rd person shooter from scratch series of tutorials with the exception that they don’t contain the input controls in the character event graph)

Here’s the target character’s event graph. This is currently crashing UE4 outright, so I’m looking into that. I think I have my possession script incorrectly setup.

Anyways, at this point, it would be great to be pointed in any better directions. I feel like I’m just forcing my way through some things and the fact that I can now crash UE4 via my BP scripts for the first time is telling me I’m not doing something right.

Hey morness-

How are the various characters in your game set up? Are they parented to the class Character or Pawn? Could you provide a screenshot of your current setup to give an idea of what you’re trying to accomplish?

Okay I’ve updated my original question with screenshots. I have gotten a little further but I feel like I’ve gone off the rails, and now I can crash UE4 outright via BP scripting.

Also all my characters in the game are setup as characters – this is because in my game, the central character is able to take possession of other characters which are controlled by AI. No AI exists yet however :slight_smile:

Okay I corrected the crash by fixing the Possess Script and now my test case actually works. But now I can’t interact with basic objects (non-pawns). I can fix that by adding new ObjectTypes to the filter. So now this question is migrating into a “is there a better way to do this?” :slight_smile:

In the end, I used SingleLineTraceForObjects supplied by Object Types of Pawn and World Dynamic, and ignoring Get Player Pawn 0, and pretty much the graphs included in the original question sans the crash – which I commented a fix.

This setup lets me jump possession of characters at will, but I still don’t feel it is totally clean.

Hey morness-

In the component graph for your goat, make sure that the Collision Presets is set to Pawn. Also click the drop down arrow next to Collision Presets and check that the Trace Responses are set as needed.

Okay, here are my current settings. It seems I cannot edit them. Doing a single line trace using the visibility channel is off… I suppose that explains why the collision won’t occur. How can I turn it on?

To enable the visibility trace response you can set the preset to custom which will allow you to edit the other settings in the collision heading.

After setting the Mesh’s Collision Presets from Pawn to Custom of type Pawn with No Physics Collision and setting trace response to block – it the ray casts still go right through. Also tried enabling Physics Collision.

It seems the only way I can get this to work is to use trace by object instead of channel.

I’m trying to match my test settings to your blueprint and was wondering what your “Interact Object Types” variable is set to?

Pawn and World Dynamic.

Having it plugged into the Trace for Objects works (as per screenshot). It’s when I originally tried to get it to work plugged into Single Line Trace by Channel that it never wants to work.

While on the subject, are there any performance differences between the two functions?

Hey morness-

It is a difference of what you’re trying to trace for. Channel is more used for different attributes of an actor such as if it is/is not visible, or if you set up a channel for “CanBePossessed”. From what I’ve gathered your best bet would be to do the trace for object and then do a check if that object can be possessed. If you are only using the trace to get the other characters you could posses you wouldn’t need to include World Dynamic in the object types.

Cheers

Thanks. I need the World Dynamic for interacting with non-character objects. I’ve just got a generic OnInteract and it’ll be up to the receiver to decide whether to deal with it or not. I also pass in the “CalledBy” character, so if I’m a tree, I can check if the character is holding an axe or something :slight_smile: