playMaker

Author Topic: How to Get Position of a cloned object?  (Read 592 times)

Adam Z

  • Full Member
  • ***
  • Posts: 151
    • View Profile
How to Get Position of a cloned object?
« on: December 20, 2017, 08:45:46 PM »
I'm using a C# script that takes a Prefab from my Project folder, and clones it when the Scene plays. I'm trying to get the position of that cloned object (every frame), and set the position (every frame) of another object that's in my Scene Hierarchy to the cloned one.

Any thoughts on how to do this?

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14585
  • Official Playmaker Support
    • View Profile
Re: How to Get Position of a cloned object?
« Reply #1 on: December 20, 2017, 11:43:20 PM »
Hi,

to get to a clone object, you have several options:

- you are aware that instantiate() return the clone object right?
- the component that instantiated keeps the reference of that cloned object in a public variable so that other script can access it
- OR the object itself is named or tag in a specific way which you can rely upon to find it by its name or tag in the hierarchy
- OR it's parented in a way that you can get it via the child index from its parent
- OR the object broadcast to everyone using an Fsm, then all interested parties receive that event and store the sender ( using action GetEventInfo) and then they have a pointer to that clone and can then work with it.

 Let me know if this is not what you are after :)

 Bye,

 Jean