Post not yet marked as solved
Loved the session, wanted to try out the demo code and then work through understanding it. 25 build errors that appear to be swift syntax related… is that just recent code changes or is there an easy fix?
Hi
I'm trying to become familiar with RealityKit 2. I'm trying to build the code in the session, but I'm getting compile errors.
Any advice?
Link to the sample code below
https://developer.apple.com/documentation/realitykit/building_an_immersive_experience_with_realitykit
Post not yet marked as solved
Can i use PhotogrammetrySession on the centos7
Post not yet marked as solved
how can I view my main Device on another device transfer data
Post not yet marked as solved
Hello !
The only way that I can use multiple animation is to have multiple USDZ with single animation
according to WWDC example
https://developer.apple.com/videos/play/wwdc2021/10074/
todo so, I should have file with single animation
but many sources like Sketchfab.. etc
it has single GLTF , USDZ file with multiple animations,
I have blender but it's too difficult to export each animation to each modeling file.
can anyone let me know how to split file by animation?
Post not yet marked as solved
https://developer.apple.com/videos/play/wwdc2021/10074/
with example that apple provide, there's dive app.
in app sampel code, there's animation sequence which is done by octopus entity.
I think this is the only way that I can do multiple animation with swift / USDZ form.
the problem is that I can't reproduce animation sequence,
so, I tweaked a little bit of sample code.
firstly,
when scene is up,
on UnderwaterView.swift,
load models function,
uncomment if state so that setupOctopus is triggered.
so, when ar app is on, octopus is appear on scene.
I changed a little bit of hidingLocation so that after 3seconds of appear octopus, it move with animation.
but the problem is octopus is moving but it shows no animation... what may be the problem?
struct OctopusSystem: RealityKit.System {
init(scene: RealityKit.Scene) {}
func update(context: SceneUpdateContext) {
let scene = context.scene
for octopus in scene.performQuery(OctopusComponent.query) {
print("oc 1111")
guard octopus.isEnabled else { continue }
print("oc 2222")
guard var component = octopus.components[OctopusComponent.self] as? OctopusComponent else { continue }
// guard component.settings?.octopus.fearsCamera ?? false else { return }
print("oc 3333\(component.state)")
switch component.state {
case .hiding:
print("oc 44444")
guard let camera = scene.performQuery(CameraComponent.query).first(where: { _ in true }) else { continue }
print("oc 555")
let fearDistance: Float = 1.0
let distanceToCamera = octopus.distance(from: camera)
print("oc 5555")
guard distanceToCamera < fearDistance else { continue }
print("oc 6666")
var hidingLocation = octopus
hidingLocation.transform.translation.x=hidingLocation.transform.translation.x-0.01
print("oc 7777")
// let distance = octopus.distance(from: hidingLocation)
// guard distance > fearDistance else { continue }
// print("oc 88")
var duration = 30.5
print("oc du...")
// Animations
DispatchQueue.main.asyncAfter(deadline: .now() + 3){
do {
let fixedTime
= component.animations.crawl2Swim.definition.duration
+ component.animations.swim2crawl.definition.duration
duration = max(fixedTime, duration)
let swimDuration = duration - fixedTime
let swimCycleDuration = component.animations.swim.definition.duration
let swimCycles = Int(swimDuration / swimCycleDuration)
duration = fixedTime + Double(swimCycles) * swimCycleDuration
if let animation = try? AnimationResource.sequence(with: [
component.animations.crawl2Swim,
component.animations.swim.repeat(count: swimCycles),
component.animations.swim2crawl
]) {
print("oc playanimation")
octopus.playAnimation(animation)
}
}
octopus.move(to: hidingLocation.transform, relativeTo: nil, duration: duration)
}
// component.state = .swimming(duration)
case .swimming(var time):
time -= context.deltaTime
component.state = time < 0 ? .hiding : .swimming(time)
}
octopus.components.set(component)
}
}
}