For our projects, all our characters have a default camera built into them. When possessing a character Unreal will automatically use the character’s camera.
Having the separate cameras in each character is nice also because different FOV settings and stuff like that. Also to query other characters camera views.
On your last point, why was I having to use Tick to get it to work at all then? How should I do it then? Thanks for all your insight btw.
I tried adding cameras back to the players and that had no effect to this effect. I may have to try making a dummy character and use that as the camera actor so I can have it auto possess a high channel like 7. Then I could set that view target w blend in the level blueprint to actually 7 and maybe it won’t give me the error that the player controller is not valid. And then perhaps I could get by using a begin play.
Spawning the character, then possession happens on the server side. It’s then replicated to you. This takes time. Once you have a Pawn and its initialized then swap cameras.
I have watched tons of videos about “player controller” and I still don’t get it. Rev has tried to explain it to me before so he certainly gets an A for effort for trying to explain it to me. And I do appreciate it.
Imho…Epic should not call it “Player controllers” but something else. And when I first seen that I thought probably like all noobs that it meant like game pads or something. The way many seem to describe it. Is the mesh would be like a chess piece. The chess piece doesn’t move without the player controller. That the player controller represents the will of the player.
In this situation, somehow that camera actor “character” needs to be assigned / associated with the player index 7, hence I can then alleviate the error right there and it should hopefully work out ok.
But…I have no idea how to do that.
All I know is, to get more than one “gamepad” input working, for me, it seems to come down to the
Create Player node. And in the game mode of that level. Looking for Player Starts in the level. (If anyone knows how to do that without player starts please let me know) Off a for each loop now I have an integer a number I can work with. Unreal assigns each gamepad a number starting at 0. But inside that Create Player node is a checkbox “spawn player controller”
So what seems to need to be done here is that camera actor character have something adjusted so that in the set view target with blend I can set it to 7 and it won’t throw the error.
The way I had been doing it was using the Set view target with blend node in the level bp. Today I tried it in the Camera Actor bp itself. And again it works with Event Tick, not Event Begin Play. But the glitch is still there.
Issue is the level is loaded way before you get your controller or pawn. Get Player Controller node returns Null. You can test this with Is Valid node.
Tick works because it’s trying 500+ times before it actually takes.
Throw a delay node (1.0) in after begin play, then call it. This is a hack (troubleshooting).
Wow ,you were right Rev, that worked. Thanks Will need to shorten the delay from 1 second some to make it more seemless. Now when the player respawns the cam is just fixed to his back. Like what you said about spawned characters getting a camera and camera manager. What can I do now?
This incredibly fast delay for the begin play to work and seem seemless. Now just need to figure out what to do when player 0 respawns to keep it from grabbing the camera authority globally
Proper way is to do all of this is either in the controller or the pawn. Call the set view target once both are fully initialized on the client. You can do this with Polling in blueprint.
Set Dependencies is a Sequence of is valid checks and sets.
e.g.
Is valid (Character)[false] → Get Controlled Pawn → Set Reference
Is valid (PlayerState)[false] → Get PlayerState → Cast → Set Reference
…
(Is valid (Character)[true] && Is valid (Character)[true]) → execute X, Else Poll Dependencies
Referencing the controller from character should use Get Controller then cast.
Referencing the character from controller should use Get Controlled Pawn then cast.
Stop using Get Player Controller (index). It is not reliable.
Ok forum, here is how the problem was alleviated, (at least for now right? lol). Rev’s comment(s) kind of indirectly helped me to solve this. especially the first one. This solution is tacky, I don’t like it, but it is one of those things like the ole "horizontal Unreal push the character smoothly or lack thereof out of the box hehe, but hey, it works.
Like he said delay the Set view target w / blend. In the camera actor’s blueprint. Feed it off an Event Begin Play, add a custom event, I called mine “Recam”. To fire again when needed.
Get a good ref for the camera actor, I got mine from the level bp since then I knew it was directly the one I needed, and set it in the gamemode, that I might easily call it in the future when needed.
Now, for me, my interest in Unreal is trying to make old arcade games. And what I ended up having to do was create “dummy” characters to exist in between the actual player characters with meshes (continue insert credits screens). What this does is “keep the mic hot” so to speak, so that all the gamepad inputs are always live and easily accessible.
The problem was the camera glitching at every respawn of player 0. So I had to add the Recam event after both the Player 0 and Dummy spawns.
With that very small delay I am not seeing the glitch.
In other news, when Event Tick gets wicked. So for old arcade games I thought the credits “widget” needs to exist all the time, always visible right? So I used ET in the game instance hahaha. What it did was actually slow the game down to a crawl after about 30 seconds. And the thing is…I would hit escape…no errors. So it took me a second to realize that THAT was one of those times when Event Tick can mess you up.
For the recursive loop to work we check to see if the references are set. You do that by checking Is Valid. The node literally see if the variable has a value. If it’s set, we do nothing and move on to the next thing. Otherwise we try to set it.
If the last clears true, we call a Ready event. Otherwise recall the polling timer event.
The reason you don’t use it is because there’s no guarantee the host is going to get a controller and pawn before anyone else. Host could get index 1 or 2 while a joining player gets 0.