I can’t get “Enable Input” to work on my NPC. I get this error
LogPawn: Error: EnableInput can only be specified on a Pawn for its Controller
Its a copy of a player character that I’m not using. I suspect that I need to dumb it down it must think its a player character and accepts only getting possessed??
Unreal engine is designed with multiplay as core component. You are trying to make singleplayer game, but it does not matter engine is designed for multiplayer. In all multiplayer games all NPCs are handled on server, only player character is handled by client. This is why you cannot enable input on non player pawn objects.
Now solution to your problem:
google for “unreal blueprint communication” follow tutorials until you have idea how it works.
make ALL iinput (keyboard, mouse etc) in your player controller
use events (and maybe event dispatchers) to send messages from player controller to npc.
Can that be done in a global player character and inherited? It’s possible that ill let them pick a character and don’t want to rewrite it all. I have seen that some things are inherited from a parent player character.
I am trying to add a widget to the screen when i interact with an NPC. the npc is a copy of one of my player characters. I can not get it to interact even with event dispatchers.
In that case, what’s the point of enabling inputs in the NPC? Isn’t the interaction triggered by some collision or some other proximity test and possibly and interaction key from the player?
Yes, I don’t mind what way it’s done but none work. I have tried when the collision box is triggered cast to npc to check that its the correct npc but the cast failed. I have used that method to check the player character is close to an actor and it worked but not here. I have also tried to set up an event dispatcher, which goes to the npc and checks if the player character is close but in never triggers the bound event in the npc. If there is a function that you can use in the player character to get the pawn or character that it has collided with that might work? Eventually there will be multiple instances of this npc so it needs to differentiate between them
Ok thanks, that worked. I was using the get character and get pawn for the object reference. Probably why the cast was failing. It might not have been able to get the npc character without the extra info?