playMaker

Author Topic: Get global position  (Read 2699 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Get global position
« on: October 01, 2017, 01:29:34 PM »
Hi,

any chance of someone making this action? I've got a debug script for it, just needs to be put in an action, something i'm not quite confident in yet and i think it will be useful to many :)

Here's the script:

Code: [Select]
using UnityEngine;
 using UnityEditor;
 
 public static class DebugMenu
 {
     [MenuItem("Debug/Print Global Position")]
     public static void PrintGlobalPosition()
     {
         if (Selection.activeGameObject != null)
         {
             Debug.Log(Selection.activeGameObject.name + " is at " + Selection.activeGameObject.transform.position);

         }
Vector3 pos = Selection.activeGameObject.transform.position;
Debug.Log("pos is now " + pos.ToString("f3"));
     }
 }
Available for Playmaker work

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Get global position
« Reply #1 on: October 01, 2017, 09:49:27 PM »
Hi,
This is actually a 'Menu item'
so not usable for actions.
i am not sure what you are trying to do, but you could make something like this :

Have an fsm somewhere and in the 1st state have a "on mouse Down" then on the next state have a mouse pick to select the object.
then you can use get position and set space to "world" next you can use debug actions or whatever you need to do (for example 'add to array list')
then after you done what you need to do, use a next frame event and loop back to the 1st state.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get global position
« Reply #2 on: October 09, 2017, 09:58:56 AM »
It is a menu item, but the logic is the same. Transform panel in the inspector shows the local position of the object, you have to deparent it to see its global position which is stupid.

Thanks for the tip, but it's too complicated, i'll try making and sharing an action :)
Available for Playmaker work

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get global position
« Reply #3 on: November 02, 2017, 03:16:09 AM »
Hi,

 can you explain your use case?

 the problem is that you are mixing editor tools with runtime tools, so this action will not work when you pubish it. You may have a good use case though, maybe you want to save data at edit time to use for level edition or something.

 bye,

 Jean

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get global position
« Reply #4 on: November 01, 2018, 08:53:19 AM »
The use case is basically everything, especially now when the nested prefabs are in the game. I can't believe they still havent implemented a simple toggle for the transform to choose between local/global.
Available for Playmaker work