playMaker

Author Topic: SOLVED Access component from spawned object  (Read 775 times)

Maart

  • Junior Playmaker
  • **
  • Posts: 88
SOLVED Access component from spawned object
« on: November 28, 2020, 07:58:40 AM »
Hi i need some help trying to do the following.
I spawn a prefab using create object. This object has a (textmesh) component that I want to manipulate. Simce it's a spawned object I cannot use something like set property from scene. I can create an object variable that holds the textmesh component. How do I assign it to the created prefab? I vaguely remember using something like set component,in the past, I can't seem to find it. Is it removed or is my mind playing tricks on me?



SOLVED
Nevermind I found the solution trough the actions "Get Component" and "set property" and creating an unityobject variable and setting it to the right ObjectType
« Last Edit: November 28, 2020, 01:29:12 PM by maart »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Access component from spawned object
« Reply #1 on: November 28, 2020, 09:20:45 AM »
Hi.
On the prefab you can have a fsm with the component in a variable (to place the variable you can drag and drop the component in the variable tab, itwill create automatically)

Call the fsm for example 'Data'

Then when you create the object, store it in a variable and use 'Get Fsm Object'
Target the stored prefab's 'Data' fsm. and the corresponding name

try minimize using Get/Set Property.

if you need actions for text mesh, maybe these can help :
https://hutonggames.com/playmakerforum/index.php?topic=15008.msg69460#msg69460

Maart

  • Junior Playmaker
  • **
  • Posts: 88
Re: Access component from spawned object
« Reply #2 on: November 28, 2020, 11:16:20 AM »
would it be better (more efficient) to send a variable and an event to the generated prefab than using get/set properties?