playMaker

Author Topic: Activate a "game object" in another scene  (Read 205 times)

Domus

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Activate a "game object" in another scene
« on: January 12, 2021, 06:25:16 AM »
Hy guys,

I'll try to explain what I'm trying to achieve, hope someone could give some suggestions.

I have a main scene, where my player is moving. In this scene, I'm able to pick up some objects (eg: a picture frame, but could be anything). When I load another scene (not the main one), I'd like to have the item picked up in loaded in the new scene (in the example, I'd like to have the picture hanged on the wall).

I'm struggling because I haven't clear how to communicate between scenes. I really want to send an event to activate an object in another scene.

Does someone have some ideas? Thank in advance!

heavygunner

  • Sr. Member
  • ****
  • Posts: 332
    • View Profile
Re: Activate a "game object" in another scene
« Reply #1 on: January 12, 2021, 06:29:15 AM »
In scene#1 - have some reference to the object. like numbers.
for eg : frame - 1, picture -2, gun -3

once player picked gun, create new int variable and set it to 3. then, use action Playerprefs set int and save it on a key

when, second scene loading, use action Playerprefs Get Int and save that key in new int variable. then, do int compare and activate the object according to it

let me know how it goes

Domus

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Activate a "game object" in another scene
« Reply #2 on: January 12, 2021, 06:32:10 AM »
Hey, thanks for the super quick reply. I'll try this night. I'll let you know!

curb47

  • Full Member
  • ***
  • Posts: 217
    • View Profile
Re: Activate a "game object" in another scene
« Reply #3 on: January 12, 2021, 08:37:03 AM »
Heavygunner - Is the technique you described more efficient/better than using variables saved to a Game Manager object set as Don Not Destroy On Load?

Or is it a different thing entirely?

Thanks.  J.

Domus

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Activate a "game object" in another scene
« Reply #4 on: January 12, 2021, 09:55:48 AM »
Hey curb47,

could you elaborate more on your solution? Sound interesting!

curb47

  • Full Member
  • ***
  • Posts: 217
    • View Profile
Re: Activate a "game object" in another scene
« Reply #5 on: January 12, 2021, 10:13:15 AM »
Sure, I'll find the question I asked here... one mo

curb47

  • Full Member
  • ***
  • Posts: 217
    • View Profile
Re: Activate a "game object" in another scene
« Reply #6 on: January 12, 2021, 10:18:31 AM »
Here you go...

https://hutonggames.com/playmakerforum/index.php?topic=22928.msg100251#msg100251

Lots of screen grabs which is quite helpful.

Domus

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Activate a "game object" in another scene
« Reply #7 on: January 12, 2021, 10:32:09 AM »
Ehy Curb! Thanks! I'll try this evening!

curb47

  • Full Member
  • ***
  • Posts: 217
    • View Profile
Re: Activate a "game object" in another scene
« Reply #8 on: January 12, 2021, 11:15:04 AM »
No worries. I'm not sure if it's applicable for your needs, but it works perfectly for me. I guess the fundamentals are simply, you have a Game Manager object (just an empty object, re-named 'Game Manager') and on that object you just give it a load of variables and you can carry the object from one scene to another, and using Get FSM Float/Integer/Bool etc etc you can get the value of any variable and then set anything in your newly loaded scene accordingly.

I guess you could have an Integer saved to the game manager and have a simple Integer Switch - if value=1 enable sword, value=2 enable picture, value=3 enable frame etc etc.

Now I know about the Game Manager / Do Not Destroy on Load technique, I really think I'll be using it in every project I do. It's a really handy thing, and you can just add more and more variables to it as your project grows.

However, to be honest, I don't know if the method HeavyGunner suggested (Playprefs) is better for you.

Good luck!
« Last Edit: January 12, 2021, 11:18:49 AM by curb47 »