# Getting Current Character for GameInstance

**URL:** <https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431>\
**Category:** Character & Animation\
**Tags:** integer, unreal-engine, Blueprint, question\
**Created:** [February 25, 2021, 8:04pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431 "2021-02-25T20:04:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakebaker865](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jakebaker865](https://forums.unrealengine.com/u/jakebaker865)\
**Post date:** [February 25, 2021, 8:04pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/1 "2021-02-25T20:04:09Z")

</div>

Hi all, I’m trying to save the current character I’m on and pass that to the game instance so that when a level is loaded it remembers the character I was on and then start the new map with the new character. You can see my switching system here: [Switch Characters - Not Mesh - Character & Animation - Epic Developer Community Forums](https://answers.unrealengine.com/questions/1010891/view.html)

Also, I posted a pic of the system

 ![330917-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/0/7f034265856a2bf5646b6ccfa1ac2d144d2e2f1d.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 25, 2021, 8:50pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/2 "2021-02-25T20:50:18Z")

</div>

Before you leave the level, stash you character class in the GI, then pull it back out on the next level:

 ![330923-screenshot-8.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/1/e113476eb68a25a8e4e26667181d4614ece96188.jpeg)

---

<div class="post-metadata">

**Author:** ![jakebaker865](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jakebaker865](https://forums.unrealengine.com/u/jakebaker865)\
**Post date:** [February 25, 2021, 8:58pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/3 "2021-02-25T20:58:12Z")

</div>

Sounds Ideal, but how would I pull my current class from the array I have at the moment? Or am I getting the current class from the gameinstance? Also, would leaving and new level be in the event graph for the gameinstance or in the “door” that is opening the new level?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 25, 2021, 9:04pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/4 "2021-02-25T21:04:22Z")

</div>

When you’re busy switching character, just keep a note of the index you used in the array. When you go to change levels, you know which class to save.

There’s as many ways to change levels as there are waves in the sea, or something like that.

Wherever you have your code to do the level switch, that’s a logical place to do what’s in the pic above…

---

<div class="post-metadata">

**Author:** ![jakebaker865](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jakebaker865](https://forums.unrealengine.com/u/jakebaker865)\
**Post date:** [February 25, 2021, 9:11pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/5 "2021-02-25T21:11:42Z")

</div>

Thank you again for the answer. I think I’m just getting stuck at how to store the class from that switching code. (I.e. Keeping a note of what index im on)

---

<div class="post-metadata">

**Author:** ![FatalBreak](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FatalBreak](https://forums.unrealengine.com/u/FatalBreak)\
**Post date:** [February 26, 2021, 5:09pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/6 "2021-02-26T17:09:52Z")

</div>

First you need to set up an actor class varable in your default game instance bp. Next, you’ll pull off the ‘Get’ for the class. At the red circle, you’ll have a ‘get game instance’ then plug that into a ‘cast to “YourDefaultGameInstance”’ and off of that, you’ll pull to ‘SetClassVariable’ and plug the get pin from the left into that node as the red line depicts.

Then on your next level, you’ll get game instance, get the class, and spawn that actor and have the player controller take control of the actor by default.

 ![331000-setclassgi.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/b/33b032d11e761f77ff49899579e19913db31afba.jpeg)

---

<div class="post-metadata">

**Author:** ![jakebaker865](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jakebaker865](https://forums.unrealengine.com/u/jakebaker865)\
**Post date:** [February 26, 2021, 10:36pm UTC](https://forums.unrealengine.com/t/getting-current-character-for-gameinstance/479431/7 "2021-02-26T22:36:53Z")

</div>

Hey man, thanks for the help. It took me a long time to get my head around what I was doing, and with some help we came up with this. Might help someone down the road. Basically made two functions that Store and load values in the game instance. I then just Store those values all around my playercontroller where needed and load them on event beginplay.

 ![331036-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/f/72f3b29c29afb08ef575694ad48c559f71471fd2.png)

 ![331035-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/6/2967399bb5424a5bf66e1a224f51fed44c104d6f.png)
