playMaker

Author Topic: Getting object position with "Get transform"  (Read 2730 times)

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Getting object position with "Get transform"
« on: January 19, 2014, 06:29:38 PM »
Hi, I'm a graphics designer (read: Unity n00b) trying to program my first mini game ::) -- a simple 2d drag'n'drop thing.

I'm trying to construct a snap-to behavior, so that when i drag an object (Obj1) across the screen and it enters the rect of Obj2, Obj1 will snap to Obj2's location.

So far I have set Obj2 up to shout out whenever Obj1 is dragged inside its collider and that works great. But I want Obj2 to send its transform (or x and y) to Obj1 -- so Obj1 knows where to "snap to".

I'm trying to use "Get transform" but it stores the result in an Object, not x and y values. How do I get x and y out of that object so that I can set Obj1's location? Or should I use another action instead?

Thanks,
/Bad
The Force is with you, young Playmaker – but you are not a C# senpai yet.

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Getting object position with "Get transform"
« Reply #1 on: January 19, 2014, 06:50:06 PM »
With obj1 selected and a FSM available in the playmaker editor click drag obj2's transform component into the state editor. This should prompt you to get or set variables and items from obj2 transform. You may want to lock obj1's graph editor before click draggin obj2.

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Re: Getting object position with "Get transform"
« Reply #2 on: January 20, 2014, 01:22:53 AM »
Thanks for the suggestion! I'll give it a try.  8)

/Bad
The Force is with you, young Playmaker – but you are not a C# senpai yet.