I’m in the early stages of trying to do a line trace from the player character to a actor.
Player would be “BP_Sprite” and actor would be “BP_Grab”. Since I’m trying to target a specific actor I’m thinking I should build an item for “Self” in an interface, and link the “BP_Grab” to that interface. Then on “BP_Sprite” call a reference to the function that references “Self”, I’m trying to use the Actor’s location as the endpoint for the linetrace.
When I add the reference to “SET_GRAB_BALL_REF” in the “BP_SPRITE” Event I have two questions:
If I’m using this right, what would I use as the target?
When I press T I get this error.
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_SET_GRAB_BALL_REF_BALL_FALL_SELF”. Node: Line Trace By Channel Graph: EventGraph Function: Execute Ubergraph BP Sprite Character Blueprint: BP_SpriteCharacter
I will take any advice even if I am going about this the wrong way. Thank you.
This seems like something I can 100% help with. However, your screenshots you’ve supplied are really blurry, probably from the aspect ratio of your 3 monitors together. Could you give individual screenshots, or snips even? I’m trying to look at your code and my eyes keep trying to unfocus, like one of those pictures you stare at until the image appears
Sorry, I have a single monitor but I snipped and stiched these images together. On my view of the image I can “download original picture” when I click on it. Do you have that option?
Okay, so it looks like you’re doing it backwards. You need to do a Sphere trace for Objects around the player, then on hit of your chosen actor type, output THAT, that’s your ball. No Interface needed But yeah, your interface was backwards, you weren’t calling anything. I think you were trying to use a dispatcher. Here, read this documentation INTENTLY because it CAN be confusing. Seriously confusing but once you get it, you GET it, you know?
Thank you for the help and reading material. I’m still a smidge confused on what to put for my “end” of the trace if I want it to trace to the detected object. It does appear to be detecting an object on the debug sphere. Wierdly, it will only detect a Pawn in the scene currently and not the actor I created. I dont want to control the sphere in the scene so i assumed the Actor was the better choice to build from.
Okay! So you’re getting it detected. Now let’s go a step further. Instead of physics body you’ll make your own channel! Unreal can carry up to 18 custom channels.
You’ll start by going to Edit>Project Settings on your main page and searching for “Channel”.
Here I have the two custom channels I’ve made in this project, “Projectile” and “Interactable”.
Click New object channel and make one for your ball, if you plan on there being other things to interact with I’d just go with something like “Interactable”.
Now go back to your sphere trace and set that “Object Types” to just include “Interactable”. Then go to your ball and set its collision on the static mesh to “Interactable”. I tend to set it like so (but you can change these):
Next, go to your Sphere Trace for Objects and right click the “Out Hit” pin. You’ll then click “Split Struct pin” and it will look like this (you can ignore where it says “Line”, we’re looking at the right side, it should be identical).
Now you’ll pull off of “Out Hit Hit Actor” and do an IsValid check, because if you didn’t hit anything you don’t want to continue.
Next, you’ll check to see if it’s your “BP_Grab”. I don’t have that so my “= Class” function is empty but you need to fill it in.
Now, provided all of those things are true,
You’ll do a cast to BP_Grab. Then tell BP_Grab to do whatever you want off of the “As BP_Grab”
@Mind-Brain I’m reading through your response, but I want to go ahead and say that I’m pretty new here. I started with Unreal Sensei’s into to unreal on youtube, then some other tutorials, then went through a udemy class on blueprints. I’m still a scrub but its nice to be able to reach out to a community with people like yourself willing to go the extra mile to make sure I understand something to thoroughly. Thanks.
To catch you up on what I’m trying to achieve, I’m making an extremely basic 2D platformer with only one mechanic. The Grapple. I want my pawn, “BP_SPRITE”, to be able to grapple and pull itself to an actor, “BP_GRAB”. I’m using some other guides i’ve found for 3d grapple and I’m trying to map that over to 2d. Hopefully this screenshot looks ok.
I’m wanting to trace to an object, and if that object is “BP_GRAB”, use its location as the end point of the trace. My new curiosity is what to use on the “HIT” of “Break Hit Result”.
So you can’t get that actor location from later down the line. It won’t have that location available because things happen in order of the white Execution line. Soooo it’s looking for a location of an object that hasn’t been found, it’s a logic break.
What you need is a sphere trace for objects, say your player’s location plus some distance of Z since they’ll primarily be above. So you’ll break the get world location on another node, add some Z value, then create vector, then plug that into your End.
Then the Radius will be how big you want the spheres to be. it will draw a whole bunch of them between the original point and the end point. That should fix some things! Get back to us soon and let us know how it’s going!
@Mind-Brain Thank you for your assistance. You helped me realize i didn’t really need to “Cast” in that particular part. I just needed location data on a class. I can now grapple after changing a few more items, however, I’m more “swinging” than pulling myself up to a point.
I think at this point maybe my old issue is resolved but my new issue moves into “fancy math problem”. I may need to repost into a new forum post?