Download

Posses an specific character on another map

Hi everyone.
I have a first map, in which my player can click on several different objects. Depending on the object clicked, the player is supposed to spawn on that character on the other map.
Right now I only have 2 boxes on the first map and two characters on the second map (each unique blueprints).

I tried before reading the “on hit” of one box, set a variable (inside a unique ActorComponent_BP and editable) to a number… in this case, the first box sets the integer variable to 1.
The problem is that on the next level the character possessed is none (I end up in position 0 0 0 and no input besides my mouse yaw and pitch) or the wrong one. I guess this might have to do that the new integer is not being saved? how can I make it save

1st level blueprint (to make sure the variable is always set to 0 at launch game)

This is the CustomEvent that is being triggered when the object feels a “hit”. I tried to set the variable to 1 (to be used in the next map) so i had to add the other box before it to join the blue strings; as it was asking for something.

This is the BP of the second level. Which is supposed to read the variable, compare it to 1 and if its true, then it spawns in Character1; if not in Character2.

This is the Blueprint of the ActorComponentBP im using to store the variable

Character in the attic BP… I noticed that beyond the first item that is hit… the next one wont trigger as if I can only use this setup for one object :frowning: any ideas on how to include many?

There might be another way to do this more efficiently but this is the only solution I came up with :slight_smile:

Any help is greatly appreciated

Since trying to figure out this, ive been getting sometimes this “Failed to create entry point. Try another location, or you may have to rebuild your level.” before simulating the game in Standalone mode… any idea why is this happening? This must be related to all this character jumping im doing… :confused:
thanks in advanced!

for data persistent between levels you need to extend the “GameInstance” class and add everything there (e.g. your “CharacterList” variable). check answerhub, there’re some explanations what GameInstance is (nothing in the docs yet unfortunately…).

Hi Ollinator,
I added a Game instance to see if it works, thanks!
I also noticed that even without moving to the new level, the variable was not being changed… any idea why? How can I make my onHit thingy interact with several different objects?

Thanks in advanced

well you’re setting your CharacterList variable to 0 on every frame (Tick), maybe you want to do that only on BeginPlay instead?
and then you’re setting it always to 1 in the hit function. you might want to assign an ID kind of variable to your Paper_A blueprints (e.g. 0 to one, 1 to the other), and pass the value of the hit/casted one to the hit function assigning it to the CharacterList variable. when you save that to the gameinstance you can then read it in the next level to decide on which character to possess.

well that would be the basic idea, hope it helps. :slight_smile:

Hi Ollinator,
You think the tick is ticking between the set to 1 node and load level? that tick sure is fast hahahhaha ill remove it and put it on BeginPlay (Does BeginPlay mean anytime that level is loaded or only once as the whole game is loaded?)
What is an ID variable? can i keep using the integre variable as it is?
How do I set it and save it in the GameInstance for future use?

While doing the GameInstance the client crashed and now my thing wont open anymore… so ill have to begin from almost 0 and try everything :confused:

thanks for your help!

I built everyting again but on the hit thing, it seems that if Im trying to make more than one stuff happen (in series) none of them will.

This is the BP of the character and the one casting the “OnHit” custom event on the paper object (what if i want it to cast another custom event if it hits another object? —Just discovered the Sequence Node, seems to work!—)
0e60e515ce82696f38a99a27c6f788cb10da538f.jpeg

This is the BP in which I try to change the integer insode the gameintance from 0 to 1 and just print it… however its not working (the variable is editable). If i connect directly to open level it works without a problem. :frowning:
863f92acc3acc9689303bee311b698d6e32cdd3f.jpeg

Any advice is welcomed!
Thanks

you have to tell the CastTo node WHAT you want to cast from (hence the empty Object pin)…in case of the gameinstance use the “GetGameInstance” node. read up here to learn how casting works:

also: dont forget to set your new gameinstance class in the project settings! (its somewhere in the maps and modes section on the bottom)

and for multiple objects implementing your hit function, check interfaces:

and:
Implementing Blueprint Interfaces | Unreal Engine Documentation

Thanks for the links! Ill read them right away!