Playmaker Feedback > Action Requests

Get global position



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: --- using UnityEngine;
 using UnityEditor;
 public static class DebugMenu
     [MenuItem("Debug/Print Global Position")]
     public static void PrintGlobalPosition()
         if (Selection.activeGameObject != null)
             Debug.Log( + " is at " + Selection.activeGameObject.transform.position);

Vector3 pos = Selection.activeGameObject.transform.position;
Debug.Log("pos is now " + pos.ToString("f3"));
--- End code ---

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.

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 :)


 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.




[0] Message Index

Go to full version