Since it’s supposed to be horizontal all the , the only thing that remains is the angle, that change is the character moves away or comes closer. I’ve tried setting up some stuff following [this] tutorial, but I have one problem: Since the guy in the tutorial has the widget face the character, rather then the camera I don’t know, how to get the location of the camera. Furthermore, I dont use ‘predefined’ cameras, but I spawn a camera actor at the start of the game and then blend to it right away:
Here is how I set things up: I come into the level, spawn a camera actor and a pawn, blend to the camera and possess the pawn. The pawn has the widget as a component. Now here is the actual problem: I actually tried promoting the return value from the spawnActor node into a variable, but the problem is, I don’t know how to access the level blueprint from another blueprint thru casting or any means at all. Thats why i stored that variable in my gameInstance as a workaround, but i when i use that variable it stays static aka it doesnt work…
That seems, like it would be working, but here is the next problem: Before i come into my map i have the player choose his character from an array of characters and then spawn the chosen character in the main map:
Now, how do i ‘dynamically’ cast to the correct character blueprint? I’ve seen a workaround, where you try all possible casts and on cast fail, you try the next one like: cast to char1 → fail → cast to char2… But i think that option is not viable, because in the final game 10 players will choose their characters and if i want to cast to char6, but someone chose char2, that cast wouldnt fail, thus giving the camera to the wrong player, right?
Generally when I run into a situation where I don’t know the class I will be needing to cast to, I would use a Blueprint interface and carry the information across in an interface function instead. BP interface functions don’t require casting and just work on any blueprint that is using the interface.
However in this case, it would simplify things considerably if you just have a camera component inside each character and use that camera when you possess the character.
Hmm, ok. Well if you don’t want to or can’t use a bp interface, another possible solution is to have the characters themselves spawn a camera actor and then posses that camera. Then the character BP would already have the return value reference inside.
I’ve been thinking about cameras as components as well, but I’ve implemented a RTS-style camera, which moves, when you hit the screen edges. However I haven’t been abel to get that to work with components, only with camera actors…
Actually I’ve thought of another solution that’s even simpler. You can use a Get All Actors of Class node. That will give you an array with all the camera actors in the scene. Assuming it’s the only camera actor in the scene, simply get index 1 (or possibly 0) from that array and there it is. =)
You can use a Get All Actors of Class node. That will give you an array with all the camera actors in the scene. Assuming it’s the only camera actor in the scene, simply get index 1 (or possibly 0) from that array and there it is. =)
You should be trying to infuence the pitch and yaw not the roll. Check to make sure your widget component is facing the same direction your character is by default. Also I see in your first screenshot that the break rotation from the “look at rotation” isn’t connected to the Make Rotation, so double check that.
I actually want to influence the roll, because I want the widget to stay horizontal at all times. Basically I want a health bar like in DotA, or any RTS pretty much. The only problem is the angle as shown in the following picture isnt adjusting:
Like I said, that means your widget (and it looks like your character as well) are facing the wrong way. Look at that blue arrow component. Your other components should be facing that direction as well.
Also, try setting the widget rotation to world/absolute rotation. It looks like It’s currently set to relative.