I think I’ve gotten the HUD pointer correctly using:
Hud = UGameplayStatics::GetPlayerController(this, 0)->GetHUD();
Now, I’m wanting to change the color of the crosshairs I made using 4 white images. I want to change the tint appearance property to green but I don’t know how to get the Image on the HUD.
I’ve looked here:
But I didn’t see anything about images. What step am I missing?
Thanks!
You can use AHUD::DrawLine() to draw crosshair with 2 lines by providing function with Start and end points and color. Same thing you can archive using AHUD::DrawRect() which also takes color as input along other variables. With this one you can make your crosshair thicker or thinner if you like. And there is also AHUD::DrawTexture() which also takes color to tint the image among other parameters. For this one you would need to provide reference to texture you want to draw. Feel free to explore and experiment. There are usually more ways to accomplish single thing in game development. Use the one that works best for you. All of above functions take color as parameter so you would need to provide them with color you want.
If you want more complete example from production you can look on Helium Rain Github repository. Whole game is made using Slate and I personally using it as great learning resource!
Yeah I had thought to try those but I was thinking it would be more profitable to learn how to get the items/widgets/images/text on my HUD blueprint since the later on there will be more things on it and I’d rather design the hud in blueprint than c++ since blueprint seems to be better for visual things. For example I am going to have two progress bar like items to keep score and another variable. I’m going to have to be able to change those from c++.
Is there not an easy way to reference the items placed on the hud canvas in unreal? If not, I may have to do the whole hud in blueprint instead of some in c++.
I updated answer with example real-world game project you can learn from.