Hi Guys, i am Fairly new at coding(started about 7 months ago) and trying to get a prototype going for my game. I do not know how about getting there from the Below statements i made up.
If PlayerController or AIController go into area of Banner, then capture Banner
‘There will be Players and AI on each team’
‘The Banner will have to change to the color of what team you are on, Blue or Red’
If Player Controller and AI(orTeam) are in same banner area, then do not do anything’
If Player Captures Banner, then play sound
If Player Banner gets captured by enemy team, then play sound
If someone could help me, it would be greatly appreciated, i am not a very social person so sorry if i was not clear or left important details out.
You have to create a material that’s using a color parameter (in a material, hold 3 and click left mouse button, then convert to parameter). Name it whatever you want. If you aren’t using any other image, just color, don’t use those Texture and Multiply nods, just a color parameter.
Create a material instance and apply it to your banner. In your blueprint create the banner reference and upon the required event set its “Color” vector parameter (you have to type in the parameter name manually) where you can choose any color you want (Y X Z are respectively Red Green and Blue).
If your question is about how to change the color, then the above answers will help you.
If your quest is about how to program the game to know WHEN the banner should change color, then you can create a Trigger Volume around the banner and every Tick increase a float value BannerContestTime while the GetOverlappingActors node returns only pawns from one team (the pawn class you cast to, or its controller or playerstate will know which team they’re on since you already put that variable in one of them I think, probably the controller?). You can loop through them and have it remember which team was the first one it found, and then it breaks the loop early and shuts the gate ahead if another team is found. upon completing the loop it proceeds to the gate node, and if that is open it proceeds to increase the BannerContestTime by the Tick deltatime amount and sets BannerContestingTeam to the team that has unanimous overlap around the banner as you found in this loop. And set the BannerContestTime back to 0 for next time somebody goes in there.
Also every tick, check if BannerContestTime is >= a default value, BannerRequiredContestTime. If it is, then change the banner to the color of the team that you set in the loop thing above.
You will want to open the gate before proceeding to the loop too, since it may have been closed from a previous run.
Once you can trigger the banner change properly, it will be easy to choose which sound to play.
If on tick the getoverlappingactors returns no pawns at all you reset BannerContestTime to 0 and set BannerContestingTeam to nothing.
If on tick the getoverlappingactors loop finds a team on one of the pawns different from the first pawn in the array, reset BannerContestTme to 0 and set BannerContestingTeam to nothing.