Change player position when changing collection SOLVED

Hi!

I try to move a player between two collections and back.
Collection 1:
player starts at one position, say far left.
Then player moves to a car and interact. This will trigger so a collection proxy is called and vill change to Collection2:
Player does somethings in this area and then move back to car. And get back to Collection 1.
Now I want the player to start at car and not at start position in Collection 1 that was in far left.

Can I set player start position or is it a way to remember it position when I start Collection 1 again?

The player objects will be different so you need to manually move them over. You could save the positions in a Lua module that both versions share, or do it with message passing.

Ok. Then I was not that far away. Have started to think about a lua module to keep state.

If a player is done with intro mission. Or collected some items and so on. Then I could store position in that.

1 Like

Hi Daniel!

My advice would be that you don’t use collections like that. You might use collections for different levels, but each level should be it’s own collection. Remember you can move the camera if you want to follow your character’s movement, and you can do everything else with game objects. If you’re using game objects, you can store the player’s position (or, for example, the entrance/exit they use for each scene) within the script.

I have controller.collection that only have a script to change between different levels, intro and start screen. That use collection proxy.

So right now I have four collections (five with controller collection that use collection proxy)
Start screen
Intro
Level 1
Level 2

And it is how the player should be positioned between level 1 and 2 when it travels back and forth depending where it is in the game. So when it starts level 1 from Intro screen I want it to be positioned at one point. When player returns from level 2 I want it to be in another position.

But the Lua module will solve some of it, can use message passing to it to store what position it should have and make the player game object get it when we create it in the collection that is loaded.

A Lua module is a good solution for this use case. You could also use Monarch to handle switching scene. Monarch allows you to pass data to a screen/scene when it is shown.

Will give it a try.

Maybe good time to do some refactoring and cleaning. :slight_smile:

1 Like