Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

transform.position vs. transform.localPosition

Discussion in 'ML-Agents' started by AndrewGri, Apr 4, 2020.

  1. AndrewGri

    AndrewGri

    Joined:
    Jan 30, 2020
    Posts:
    12
    Most probably this is very silly question.
    When I look into ML Agents examples I see that agent scripts use transform.position when resetting agent.
    But when I do that after making clones of my arena I get all agents only on one arena. To fix that I use transform.localPosition. I also use transform.localPosition in agent observations.
    But how ML Agents examples work then, because they also use arena cloning?
     
    Last edited: Apr 4, 2020
  2. awjuliani

    awjuliani

    Unity Technologies

    Joined:
    Mar 1, 2017
    Posts:
    69
    Hi AndrewGri,

    We use localPosition for observations because we care about ensuring that the agent "sees" the world relative some semantically meaningful center point. In Unity localPosition corresponds to the position of the parent object, in this case the Arena. Position on the other hand is the global position.