Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: zuzundra on October 24, 2015, 08:47:39 AM

Title: Problem with getting GameObject.Transform from Unity script
Post by: zuzundra on October 24, 2015, 08:47:39 AM
Hi All!  :)

I have a task:

there are a few objects in the scene (Ally_obj, Enemy_obj_1, Enemy_obj_2, Enemy_obj_3).
On Ally_obj is a script that finds nearest target and store it.
After target is founded i need to Move Ally_obj to target position by Itween action.

Please, could anybody explain, how could i get target position by Playmaker to use ItweenMoveTo then.

Great thanks for helping! :-[
Title: Re: Problem with getting GameObject.Transform from Unity script
Post by: ManicMinerUK on October 25, 2015, 12:00:15 AM
if you want to retain the original script then you will need to talk to someone with more experience of integrating playmaker with existing unityscript/c#, but you could fairly easily do this entirely within playmaker.

The Ally_Obj could have an FSM that uses the "Find Closest" action (which might be a standard PM action, or might be available from the Ecosystem) to store the closest enemy object in a game object variable.

Then you can do a Get Position action, using that variable as the target, and stores the position as a Vector3.

That Vector3 could then be used as the target position of an itween to create your movement.

Title: Re: Problem with getting GameObject.Transform from Unity script
Post by: zuzundra on October 25, 2015, 03:23:36 AM
Yep, it could be a solution.

But i need to use gameobject variable exactly from my unity script.
I thought that it could be smth like Get Property action... but it doesn't working...
Title: Re: Problem with getting GameObject.Transform from Unity script
Post by: dudebxl on October 25, 2015, 04:02:51 AM
Well, if you are not going to use playmaker than you need to script? Is your gameobject var public? If no htne mak eit public and try the get prop.
 are you currently getting the closest object vector3 position?

If you are then make sure the vector3 var is public and use get prop.
If not then google on how to get gameobject vector3 position and key it into your script. Then do as above.. This should only take 10 minutes..
Title: Re: Problem with getting GameObject.Transform from Unity script
Post by: zuzundra on October 25, 2015, 07:04:52 AM
Thanks for suggestion!
Really, problem was in getting non-static PlayMakerFSM...I publish and make it public in my Unity script. And the problem was solved!

Great thanks to dudebxl!
Title: Re: Problem with getting GameObject.Transform from Unity script
Post by: BryanO on April 21, 2016, 11:34:38 AM
What exactly does this mean - that your fsm wouldnt work (in edit mode) until you made a full build? What was the solution the answers you got were ppl giving 1/2 answers or work arounds not what you asked.