Cast to Player Controller

Hey, I have a trouble… I want to cast my custom event that is on my actor named GhostTP by pressing X button on my another actor: Fox

Blueprint in GhostThirdPersonCharacter:
http://prntscr.com/jcdgsk

Blueprints in FoxThirdPersonCharacter (When your Press G, Casts to GhostTP and execute an custom event):
http://prntscr.com/jcdcob

The issue is, I don’t known what place to Target on Cast to GhostTP.

This is actually a perfect example of a good reason to use Event Dispatchers. I would recommend using those in place of this, because in order to cast, you will need to get a reference of it somehow.

Are you familiar with dispatchers?

Nope, im pretty new on Unreal Engine. I should watch now 20 YouTube tutorial?

It would definitely help and I can assure you wouldn’t be disappointed learning them - gaining the knowledge on how to use dispatchers is extremely valuable in my opinion.

link text

Ok, thanks :slight_smile:

The problem now is that I don’t known what put on the ‘Object’ on Cast to GhostTP. I’ve tried with ‘Get Player Controller’, ‘Get Player Character’, etc… But nothing works, the problem wasn’t the event because if I put a ‘print string’ after Cast To, nothing happens.

If you’re still having trouble with this, can you toss up some new screenshots of the BP as it is now, and maybe we can shoot some ideas…

Easier said than done, but you are not referencing that other character (I believe this is just another pawn and not your main character, correct?) Therefore, the ‘Get Player Character’ & ‘Get Player Controller’ probably isn’t working because they are likely referencing the main player character at Index 0.

However, as I stated near the beginning of the thread, I really think an event dispatcher would suffice in this scenario, if I’m understanding your situation correctly. In that case, you would only need to cast to your main character from the GhostTP. Actually, you may not be able to cast to GhostTP if there isn’t a way to get a valid reference with what you are trying to do.

How and where to execute game logic, is ■■■■ near half the battle sometimes i’ve come to find. so you may only have the option of using either a dispatcher or a function interface for BP-to-BP communication.

if you put a print string on both output pins of the cast and nothing happens then your issue lies elsewhere, it means that node is never being called. if your getting the print to work on the false pin then the issue is the object input. for the object input you need a reference to the thing your casting to. so you will need a reference to a ghosttp that is in your level.

That cast is always going to fail because you are asking for the “controlled pawn” which by the way you worded your question seems to be “Fox”. If pressing the “X” button causes “Fox BP” to do something then your “controlled pawn” is Fox NOT Ghost, hence the failing cast. What you need is a direct reference to “Ghost” from an overlap event, hit event, some kind of event or if all else fails and you only have 1 Ghost in your level “get all actors of class” node and THAT is what you connect to the object input pin on the cast node.

I have 1 Ghost in the level. Yeah, it works when I put ‘Get all actors from class’ but the things what happens only are visible for the Fox and not the Ghost: Casting to other actor doesn't work correcctly - Multiplayer & Networking - Unreal Engine Forums

Also, if I put Out Hit—>Break hit result---->Hit actor----->Cast to GhostTP
it fails.

It can print strings on Cast Failed. Only works on the successful node when I put a ‘Get All Actors from class’ and not Cast To Ghost TP. (Here’s the URL: Casting to other actor doesn't work correcctly - Multiplayer & Networking - Unreal Engine Forums )

Don’t known how to do a reference, something like this Screenshot by Lightshot ?
(Im the worst noob on unreal engine)

Sounds like an issue with server-client replication and I do not have enough experience in that area to advise you further sorry that is a separate issue from a failed cast.

thats how you create a variable which is one step in the right direction but you would need to set the value of that variable to a ghost in your level through the use use of a trace, collision event, or by manually setting via a public variable. though from what your saying in response to nebulas comments your question has become unclear. is this a multiplayer project? and you say that you issue works some of the time but doesnt show to all players, so that sounds like a replication issue in which case i wont be of much help since i dont really mess around with multiplayer

Yes, it works only for the player who wants to Cast the event of other player.

Looks like this: If the Fox wants to call the event of the Ghost, the event going to appear to the Fox view but not into the Ghost. If the Ghost wants to call his own event, the event will probably appear in both screens…

Seems like ‘I want to to call my friend with my telephone, I can hear his voice but he can’t listen to me and hear himself. But if he calls me, we can speak and listen correctly, but it can’t call me because he doesn’t have my number and Im the unique who can call it’

Yeah, ■■■■■■■ looks like a replication issue. But this is pretty strange, im calling for a event wich is located on the Ghost, and the animation isn’t visible on the Ghost, only on the fox. Woah, Unreal Engine is… Very complete, I shouldn’t have started my first project in a multiplayer game.

Here are some Screenshots:
-----In Fox pawn-----
-Before the line tracer: http://prntscr.com/jl6yt1
-After the line tracer 1/2: http://prntscr.com/jl6zcz
-After the line tracer 2/2: http://prntscr.com/jl6zx4

-----In GhostTP-----
-Dispatcher+Event: http://prntscr.com/jl70ph
-Event of dispatcher: http://prntscr.com/jl71v8

What it does: http://prntscr.com/jl733w

How the multiplayer automatic character select works: http://prntscr.com/jl74dq
If the Player is the server, it sets to GhostTP. If the Player is the who join into the server, it sets to Fox. A ■■■■■■■ stupid way to do this, but it works lol.

Ok, I’ve solved it by myself. I had to replicate the dispatcher with 2 events; One for the server and another with multicast. So the event dispatcher wasn’t necessary at all, the real issue was the replication.

But I going to mark you as the correct anwser for helping, and the dispatchers going to help me in the future (Like for effects when the Ghost was hit, or make other events to happen like lost life, etc). I want also want to upvote to @ThomsonN13 and Nebula Games Inc, but I can’t lol.