- Home /
Playmaker prefab issue
Good afternoon, here I am, again, with another problem, this time using playmaker. I set up a very basic enemy, which, depending on the tag given to the FPS, will give two "effects", one will damage and the other will increase the bar of life points, and then destroy itself. I used the collider of the enemy as a trigger, (a cube), then take the information from the slider (Get and Set Property) and set it up after the damage / restore. So far it's all right, but when I do an enemy prefab, and close Unity, this will lose references, so I have to set it all up. I'm sure I miss something, please, what it is?
Thanks in advance.
Answer by justDeek · Sep 02, 2017 at 06:06 PM
Get Property and Set Property use local references which shouldn't be used in Prefabs (because they are designed to be portable and dismiss any local references), so you have to use variables and pass information at runtime either inside the same FSM or through Global Variables, Prefabs / save files (like text, xml, json, ...).
Example:
That Game Object "Main Camera" won't get transfered over if I would make a prefab out of the GameObject with this FSM while this:
works if I feed the variable "mainCamera" with a GameObject at runtime (even though in this case the variable "mainCam" would be renderer useless but it's just to show the difference).
But you can however use local references if you make an instance of that prefab and insert your local references afterwards; it's just not the recommended approach but would still work.
Only if you press 'Apply' on your instance the local references won't get transfered over to other instances and if you create instances at runtime you can't use local references inside the prefab.
BTW PlayMaker also has an active Forum with a 'Help' section, where you'd have more luck getting answers on such topics than here. (http://hutonggames.com/playmakerforum/index.php)
Answer by elia-demarco · Sep 03, 2017 at 01:34 PM
I see, I'll store informations via globals and see what happen, I really appreciated your explanation, simple and clear, you even include images for example, thank you very much. I'll check Hutong forum for future issues with playmaker.