title: iOS RealityKit. Changing Entity's translation causes unexpected behaviour
body: <p>I am trying to create some AR experience.</p>
  <p>I load the <strong>Model</strong> with animations as an <strong>Entity</strong>. Lets call it a <strong>Toy</strong>.
  I create an <strong>AnchorEntity</strong>.
  I attach the Toy to the <strong>AnchorEntity</strong>. Up to this point everything works great.</p>
  <p>I want the <strong>Toy</strong> to walk in random directions. And it does for the first time. Then it gets interesting, allow me to share my code:</p>
  <p>First method uses a newly created <strong>Transform</strong> for the <strong>Toy</strong> with the modified translation <strong>x</strong>, <strong>y</strong>, to make the <strong>Toy</strong> move and that is it.</p>
  <pre class="lang-swift prettyprint-override"><code>func walk(completion: @escaping () -&gt; Void) {
          guard let robot = robot else {
              return
          }
          let currentTransform = robot.transform
          guard let path = randomPath(from: currentTransform) else {
              return
          }
          let (newTranslation , travelTime) = path
          
          let newTransform = Transform(scale: currentTransform.scale,
                                       rotation: currentTransform.rotation,
                                       translation: newTranslation)
          
          robot.move(to: newTransform, relativeTo: nil, duration: travelTime)
  
          DispatchQueue.main.asyncAfter(deadline: .now() + travelTime + 1) {
              completion()
          }
      }
  </code></pre>
  <p>We get that new <strong>Transform</strong> from the method below.</p>
  <pre class="lang-swift prettyprint-override"><code>func randomPath(from currentTransform: Transform) -&gt; (SIMD3&lt;Float&gt;, TimeInterval)? {
          // Get the robot's current transform and translation
          let robotTranslation = currentTransform.translation
          
          // Generate random distances for a model to cross, relative to origin
          let randomXTranslation = Float.random(in: 0.1...0.4) * [-1.0,1.0].randomElement()!
          let randomZTranslation = Float.random(in: 0.1...0.4) * [-1.0,1.0].randomElement()!
          
          // Create a translation relative to the current transform
          let relativeXTranslation = robotTranslation.x + randomXTranslation
          let relativeZTranslation = robotTranslation.z + randomZTranslation
          
          // Find a path
          var path = (randomXTranslation * randomXTranslation + randomZTranslation * randomZTranslation).squareRoot()
          
          // Path only positive
          if path &lt; 0 { path = -path }
          
          // Calculate the time of walking based on the distance and default speed
          let timeOfWalking: Float = path / settings.robotSpeed
  
          // Based on old trasnlation calculate the new one
          let newTranslation: SIMD3&lt;Float&gt; = [relativeXTranslation,
                                              Float(0),
                                              relativeZTranslation]
          
          return (newTranslation, TimeInterval(timeOfWalking))
      }
  </code></pre>
  <p>The problem is that the value of <strong>Entity.transform.translation.y</strong> grows from 0 to some random value &lt; 1. Always after the second time the <strong>walk()</strong> method is being called.</p>
  <p>As you can see, every time the method is called, newTranslation sets the Y value to be 0. And yet the Toy's translation:
  <a href="https://i.stack.imgur.com/AC5RK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AC5RK.png" alt="enter image description here" /></a></p>
  <p>I am out of ideas any help is appreciated. I can share the whole code if needed.</p>