title: Applying downward force to an object using RealityKit
body: <p>Here is my previous question about <a href="https://stackoverflow.com/questions/71046250/realitykit-add-force-to-entity-at-specific-point">in general apply force for a certain point of an AR object</a> which had a perfect answer.
  I have managed to apply force to a given point with a little bit of tinkering to have a perfect effect for me. Let me show also some code.</p>
  <p>I get the AR object from <code>Experience</code> like:</p>
  <pre class="lang-swift prettyprint-override"><code>if let skateAnchor = try? Experience.loadSkateboard(), 
     let skateEntity = skateAnchor.skateboard {
  
      guard let entity = skateEntity as? HasPhysicsBody else { return }
      skateAnchor.generateCollisionShapes(recursive: true)
      entity.collision?.filter.mask = [.sceneUnderstanding]
      skateboard = entity
  }
  </code></pre>
  <p>Afterwards I set up the plane and the LiDAR scanner and add some gestures to it like:</p>
  <pre class="lang-swift prettyprint-override"><code>let arViewTap = UITapGestureRecognizer(target: self, 
                                         action: #selector(tapped(sender:)))
  arView.addGestureRecognizer(arViewTap)
  let arViewLongPress = UILongPressGestureRecognizer(target: self, 
                                                     action: #selector(longPressed(sender:)))
  arView.addGestureRecognizer(arViewLongPress)
  </code></pre>
  <p>So far so good, on tap gesture I apply the logic from the previously linked answer and apply force impulse like:</p>
  <pre class="lang-swift prettyprint-override"><code>if  let sk8 = skateboard as? HasPhysics {
      sk8.applyImpulse(direction, at: position, relativeTo: nil)
  }
  </code></pre>
  <p><strong>My issue comes with my &quot;catching&quot; logic, where I do want to use the long press, and apply downward force to my skateboard AR object</strong> like this:</p>
  <pre class="lang-swift prettyprint-override"><code>@objc func longPressed(sender: UILongPressGestureRecognizer) {
      if sender.state == .began || sender.state == .changed {
          let location =  sender.location(in:arView)
  
          if arView.entity(at: location) is HasPhysics {
  
              if let ray = arView.ray(through: location) {
  
                  let results = arView.scene.raycast(origin: ray.origin,
                                                  direction: ray.direction,
                                                     length: 100.0,
                                                      query: .nearest,
                                                       mask: .all,
                                                 relativeTo: nil)
  
                  if let _ = results.first,
                     let position = results.first?.position,
                     let normal = results.first?.normal {
  
                      // test different kind of forces
                      let direction = SIMD3&lt;Float&gt;(0, -20, 0)
                          
                      if let sk8 = skateboard as? HasPhysics {
                          sk8.addForce(direction, at: position, relativeTo: nil)
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Right now I know that I am ignoring the raycast results, but this is in pure development state, my issue is that when I apply positive/negative <code>x/z</code> the object responds well, it either slides back and forth or left or right, the positive <code>y</code> is also working by draging the board in the air, the only error prone force direction is the one I am striving to achieve is the downward facing negative <code>y</code>. The object just sits there with no effect at all.</p>
  <p>Let also share how my object is defined inside the Reality Composer:</p>
  <p><a href="https://i.stack.imgur.com/4tEi2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4tEi2.jpg" alt="skateboard inside the Reality Composer " /></a></p>