Make an object move

I Want to make an entity move. I have added an onTap function that now works and registers touches. But I can't seem to make the entity move. I copied this code from session 605


@IBAction func onTap(_ sender: UITapGestureRecognizer) {

let tapLocation = sender.location(in: arView)

print("I am here at onTap")

// Get the entity at the location we've tapped, if one exists

if let object = arView.entity(at: tapLocation) {

// For testing purposes, print the name of the tapped entity

print(object.name)

// Add interaction code here

var flipUpTransform = object.transform

flipUpTransform.rotation = simd_quatf(angle: .pi, axis: [1, 0, 0])

let flipUpController = object.move(to: flipUpTransform, relativeTo: object.parent, duration: 2.0, timingFunction: .easeInOut)

print("I think I just moved")

flipUpController.completionHandler {

// box is finished flipping

}

}

}

Replies

I Can make the object move or scale explicitly.


I Can set object.scale = simd_float3(2,2,2) and get it to jump to that scale on tap, but I can't seem to get it to animate to that scale.


...or rotate, or translate.


After I set the flipUpController variable, do I need to execute it someway?


let flipUpController = object.move(to: flipUpTransform, relativeTo: object.parent, duration: 2.0, timingFunction: .easeInOut)


If I understand it correctly, this is creating an animationPlaybackController. Do I need to tell it to play somehow?


thanks,

Dale