playMaker

Author Topic: Sending a Player into another Scene  (Read 4089 times)

SeriousRPG

  • Playmaker Newbie
  • *
  • Posts: 45
Sending a Player into another Scene
« on: December 01, 2013, 08:40:36 PM »
Hi;
I have a player that I want to send to another scene when they walk into a trigger. Basically, my scene1 is a city with exteriors and scene2 is an interior scene. When I 'walk' into a building by hitting a trigger, I need my character to move to somewhere (spawnpoint) in scene2. The spawnpoint in scene2 doesn't exist in scene1 and the character needs to be passed in because it may be mesh1 or mesh2 or mesh3 depending on the user's selection of a character at the beginning of the game.

I seem to be having problems because when I move to the new scene, the FSM variables (player) is lost and the 'create object' says there is no target specified, nor can it find the spawnpoint.


caesarhernandez

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Sending a Player into another Scene
« Reply #1 on: December 01, 2013, 09:02:53 PM »
Hi Sandy,

I think you could use a global variable. I would create an empty GameObject then make a prefab out of it. Drag the instanced prefab into your second scene where you want your player to spawn then hit "apply" so it updates the original prefab. Next, create a global variable that is of type gameobject, then drag/drop the prefab (not the instance of it) GameObject you created that is instantiated in your second scene. You should be able to then use this global variable for your spawn point ( I think :) )

~Caesar

caesarhernandez

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Sending a Player into another Scene
« Reply #2 on: December 01, 2013, 09:19:47 PM »
You don't need the global variable. Just use the prefab as the transform position for where you want your player to spawn. Here are the steps:

- create scene 1
- create scene 2
- create a prefab playerSpawnPoint
- create an empty gameobject in scene 2
- drag the gameobject onto the prefab
- delete the gameobject from the scene
- drag the prefab onto the scene
- move the prefab where you wish your player to be spawned
- click "apply" in the inspector
...now you have a position to spawn your player. You can drag the prefab into any FSM and get the transform location.

~Caesar

SeriousRPG

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Sending a Player into another Scene
« Reply #3 on: December 02, 2013, 08:44:15 PM »
Hi;
It's not quite working. I load to the Scene2, my camera is at the SpawnPoint but my character is not there.

In the FSM on the 'portal' in Scene1, I load Scene2, then in the next state I am using Create Object (CharPrefab, SpawnPointPrefab). How do I make my Character appear in the new scene?

Thanks,

Sandi

caesarhernandez

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Sending a Player into another Scene
« Reply #4 on: December 03, 2013, 10:51:31 AM »
I don't think you can do that. Once the action to load a scene is hit, nothing else should happen after that because the new scene is loading (unless you are using load scene additive or something). You can test this by setting breakpoint on your Create Object state (right-click, toggle breakpoint) - it should not be executed if it follows your load scene state. You have to spawn the character from scene 2 using your character and spawnpoint prefabs.

SeriousRPG

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Sending a Player into another Scene
« Reply #5 on: December 03, 2013, 05:50:53 PM »
Ok, so how do I spawn the character in Scene2 programmatically, because from this point all I have really done is load scene 2? Do I need to send an event from this FSM (the 'traveller that arrived at the scene') to another FSM that is attached to something in the Scene 2 and use the Create object from there?

Sandi

caesarhernandez

  • Playmaker Newbie
  • *
  • Posts: 30
Re: Sending a Player into another Scene
« Reply #6 on: December 04, 2013, 09:37:38 AM »
Do you need to send the traveler to a different location each time from scene 1 to scene 2? If so, you need to just store the location in a global variable in scene 1 then recall the global variable in scene 2 and use that location when you instance the object.