Download

Getting Actor Info into the PlayerController

Hi together,

maybe first, what I try to do. I have a PlayerCharacter which should only be able to move inside the camera constraints. With an orthographic camera postion x = 0, y = 0 and z = 10000 and an orthographic width of 3000 my Player Character should be able to walk -1500 left, 1500 right and lets say with an aspect ratio of 1 the same for up and down. Doesnt Matter for my Problem.

I have the movement in place, I clamp it to a fixed value right now in the PlayerController Class. But I want to vary the orthographic width while playing, so I have to let th Player Controller know what the actuall orthographic width is. Due to the fact that the Player Controller isnt a default blueprint I have some problems with that.

  1. The Player Controller cant have Objects as public variables. You can add them as public but they dont get exposed to edit them. Most likely because the player Controller is instanticated before the map and therefore does not know about any Actor objects, it only know about actor classes. (Right??)

  2. My Main Camera is also a Blueprint where I blend to with Game Start Event.

  3. I added an Interface to the Main Camera Blueprint with a return value of the Camera orthographic width.

  4. Inside the Player Controller I added a Varible to the Main Camera CLASS (as said object is not possible or I do something wrong).

controller.jpg

  1. Now I try to get all instances of the main camera (see Screenshot, this isnt ment as a final solution, it is for testing only!) and use the interface to get the camera orthographic width. But that is not working at all. The array of cameras is alway 0 but I have a “TheMainCamera” instance in the View which is working fine.

Is my Setup Wrong?
Is there some kind of a Blueprint singelton so you dont have to loop through all instances when you already know there is only one (in this example) main camera?

Thanks for reading and best regards,
Isa

I am not sure if that is the propper way to do it (getting an array of a class just to get the main camera seems a bit messy to me) but it is working now. The Problem was, that the BP did not accepted the class variable as input for the “get all Actors of class” because the variable was set to the correct class but was empty. I removed the input and set the class of the “get all Actors of class” module directly in the pull down menu of that block and it worked.