playMaker

Author Topic: Problem with getting GameObject.Transform from Unity script  (Read 2373 times)

zuzundra

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Problem with getting GameObject.Transform from Unity script
« on: October 24, 2015, 05: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! :-[

ManicMinerUK

  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Problem with getting GameObject.Transform from Unity script
« Reply #1 on: October 24, 2015, 09:00:15 PM »
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.


zuzundra

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with getting GameObject.Transform from Unity script
« Reply #2 on: October 25, 2015, 12: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...

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Problem with getting GameObject.Transform from Unity script
« Reply #3 on: October 25, 2015, 01: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..

zuzundra

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with getting GameObject.Transform from Unity script
« Reply #4 on: October 25, 2015, 04: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!
« Last Edit: October 25, 2015, 08:48:41 AM by zuzundra »

BryanO

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with getting GameObject.Transform from Unity script
« Reply #5 on: April 21, 2016, 08: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.