playMaker

Author Topic: Ideas for setting the player model  (Read 3125 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Ideas for setting the player model
« on: September 10, 2013, 03:27:07 PM »
Hi,

I need a way to set the player model in one place, and have that model be reused wherever it is needed.

I have a spawn control utility FSM that is placed in every scene. It looks to a global that tells it wher ethe player currently is, and then loads the player to that location in the new scene.
Imagine a building with 2 entrances. The player can enter from either door, the scene containing the interior is loaded and the player is spawned to the loaction of the that door INSIDE the building, instead of a generic start point.
This works.
But I am Hard-Coding the player name in the Create Object Action everytime.

But now I want to be able to change the player type, to that of a different character (Imagine that the User can choose which character to play). How can I set some kind of "top level" setting that can then populate into all the many places I currently have to manually drag my Player.prefab.

Did this make sense?

Mark

parallel

  • Full Member
  • ***
  • Posts: 155
Re: Ideas for setting the player model
« Reply #1 on: September 10, 2013, 04:03:26 PM »
How about a player manager; each game generates a player_name which gets to be a child of a current_player gameobject, being the one to spawn and getting its position from player_name. I'm a noob with PM but am curious if that would work. 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Ideas for setting the player model
« Reply #2 on: September 11, 2013, 03:17:24 AM »
Hi,

 If I am following, two options:

1: use arrayMaker with a hashtable to store your different player prefabs and reference them with strings. ( like "Wizard","Witch","dog", etc each pointing to the right prefab)

then when you need to spawn it, you look it up in that hashtable to know which prefab to load.

2: move your prefabs in a "Resources" folder, and load them by their name ( which you can compose as regular string, using the following custom action:
http://hutonggames.com/playmakerforum/index.php?topic=3916.msg19802#msg19802

Bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Ideas for setting the player model
« Reply #3 on: September 11, 2013, 10:01:46 AM »
Thanks for the replys guys!

I see what YOU mean Parallel, I think its sounds easy, it may work... thx for the suggestion...

I have tried arrayMaker in the past, and I havent got it to work (but will try it again, as Im certain I need it in the future, I certainly dont know what a hashtable is...).

Jean can you explain why the "move to resources" folder please? Not a problem, just I want to understand.
Do you mean that instead of draggin in my player prefab into the Create Action, I use a string and then CHANGE the string with this custom action.. will that work---?

OK Ill try it..



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Ideas for setting the player model
« Reply #4 on: September 13, 2013, 05:26:29 AM »
Hi,

 "Resources" folders are special folders ( not the capital R, important)

anything in such folders ( you can many in your projects) will have all of its content available in your published environment. To access resources, you then use "load resource" custom action mentionned above, simply by referencing its filepath ( all resources are relative to the "Resources" folder.

http://docs.unity3d.com/Documentation/ScriptReference/Resources.html

does that help?

Bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Ideas for setting the player model
« Reply #5 on: September 13, 2013, 10:15:16 AM »
Yes that makes some sense Jean, thanks!

A one line explanation of "Hashtable" now please?
:)