# How to make a cooperative system that shares the same hud

**URL:** <https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [August 10, 2015, 8:10pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148 "2015-08-10T20:10:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_40a407b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_40a407b6](https://forums.unrealengine.com/u/anonymous_user_40a407b6)\
**Post date:** [August 10, 2015, 8:10pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148/1 "2015-08-10T20:10:35Z")

</div>

I have two characters under the same parented class, set up with a flip flop to switch between the two. I am trying to make a cooperative system that will share the same hud for picking up coins in the level. Right now, the flip flop works fine in possessing each character. But, I noticed the coin counter is dependant on which character picks up the coins. I.E. Char1 picks up 100 coins, then I switch to Char2. The coin counter then says 0 coins. He picks up 10 coins. I switch back to Char1, and the coin counter returns to show 100 coins. Is there a way to make this so any coins picked up, no matter which character is possessed will add to the same counter?

I need this to happen because one of the objectives in the level is to pick up a set total of coins.

---

<div class="post-metadata">

**Author:** ![\_cDub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_cDub](https://forums.unrealengine.com/u/_cDub)\
**Post date:** [August 10, 2015, 9:04pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148/2 "2015-08-10T21:04:29Z")

</div>

Keep track of the coins collected in either the player controller or the player state.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_40a407b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_40a407b6](https://forums.unrealengine.com/u/anonymous_user_40a407b6)\
**Post date:** [August 10, 2015, 9:29pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148/3 "2015-08-10T21:29:16Z")

</div>

How would I set that up exactly? Still trying to learn the ins and outs of blueprints, sorry.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [August 10, 2015, 10:02pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148/4 "2015-08-10T22:02:05Z")

</div>

Use “GetPlayerController” and cast this to your Custom PlayerController Blueprint, that you either already have created  
or that you might want to create right now (you need to set this to the Default ControllerBlueprint Class in your GameMode Blueprint).  
Then, in your custom PlayerController Blueprint, create your Score variable and after casting it (the GetPlayerController and Cast happens  
in both Characters, so you could put this logic in their Parent Class) you get the variable, add 1 to it and set it again.

Now you can access your Controller Class also in the HUD and since both character save the score in the same Controller, you will  
have the summed up value.

You could also use the PlayerState Class which is more suited for this. You will do this same thing with Creating your own PlayerState  
Class with PlayerState as a Parent and set it as the default PlayerState class in your GameMode. You can access this ClassActor  
over the PlayerController. Just do this: GetPlayerController-\>GetPlayerState-\>Cast PlayerState To your CustomPlayerState-\>Change Score

So pretty much the same, but only another class that was made for saving scores.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_40a407b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_40a407b6](https://forums.unrealengine.com/u/anonymous_user_40a407b6)\
**Post date:** [August 10, 2015, 10:15pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148/5 "2015-08-10T22:15:20Z")

</div>

> [@eXi;352861](#):
>
> Use “GetPlayerController” and cast this to your Custom PlayerController Blueprint, that you either already have created  
> or that you might want to create right now (you need to set this to the Default ControllerBlueprint Class in your GameMode Blueprint).  
> Then, in your custom PlayerController Blueprint, create your Score variable and after casting it (the GetPlayerController and Cast happens  
> in both Characters, so you could put this logic in their Parent Class) you get the variable, add 1 to it and set it again.
> 
> Now you can access your Controller Class also in the HUD and since both character save the score in the same Controller, you will  
> have the summed up value.
> 
> You could also use the PlayerState Class which is more suited for this. You will do this same thing with Creating your own PlayerState  
> Class with PlayerState as a Parent and set it as the default PlayerState class in your GameMode. You can access this ClassActor  
> over the PlayerController. Just do this: GetPlayerController-\>GetPlayerState-\>Cast PlayerState To your CustomPlayerState-\>Change Score
> 
> So pretty much the same, but only another class that was made for saving scores.

Thank you! That worked perfectly using the player state!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_40a407b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_40a407b6](https://forums.unrealengine.com/u/anonymous_user_40a407b6)\
**Post date:** [November 20, 2015, 6:42pm UTC](https://forums.unrealengine.com/t/how-to-make-a-cooperative-system-that-shares-the-same-hud/38148/6 "2015-11-20T18:42:25Z")

</div>

Tried to post this earlier, but it didn’t show up. Sorry if it ends up posting twice…

So, all of a sudden, my player state stopped working. Kept getting an “Accessed NONE error” whenever I would try to pick up coins, and nothing would add to the total in the counter. I thought it was possibly just a currupt file, so I duplicated it manually, but it was still not working. So, I redid the programming, using the player controller instead. This worked to a degree, meaning it works in the current map, but the total resets when I load the next map in the level. I am sure this is something simple, but I am just not seeing it. Any idea what I am missing?
