So I have cloned the Scavenger Hunt and got it working in my local area. However when IRL testing if I return out of an AR interaction back to the map view I am now located well above Doty to the point where he is off the bottom of the screen. The map seems to still move with my movements but my view positioning seems to be off in height. Reloading the page fixes of course, but am I missing something in the settings?
Tested on another iphone browser and it still does the same.
Hi Richard,
I am facing the same issue.
Have you found a fix for this? I think it has to do with the camera coordinates when moving from AR World type back to 3D in the World Map scene. I also tried moving the camera entity within the components hierarchy but no luck. AI suggest it is the Camera Controller script, as that only controls the manual rotation of the world map view with user scroll. Basically having the camera follow doty and below is the script I tried but now facing a different issue.
import * as ecs from '@8thwall/ecs'
/**
* Keeps the map camera positioned behind Doty and
* rotates both the camera and Doty to face the user's current yaw.
* - followTarget: Doty entity (player avatar on the map)
* - faceTarget: Usually the same Doty entity; rotate it to match camera yaw
* - height: Camera height above Doty
* - distance: Camera distance behind Doty (along -Z in world space)
*/
ecs.registerComponent({
name: 'World Map Camera Controls',
schema: {
followTarget: ecs.eid, // Doty
faceTarget: ecs.eid, // Doty (or any entity you want to face the yaw)
rotationSensitivity: ecs.f32, // yaw sensitivity
height: ecs.f32,
distance: ecs.f32,
},
schemaDefaults: {
rotationSensitivity: 8.0,
height: 1.8,
distance: 6.0,
},
data: {
yawDeg: ecs.f32, // absolute yaw we apply to camera + Doty
},
stateMachine: ({ world, eid, schemaAttribute, dataAttribute }) => {
const snapCameraBehindFollow = () => {
const { followTarget, height, distance } = schemaAttribute.get(eid)
if (!followTarget) return
// Get Doty (follow target) position
const followPos = ecs.Position.get(world, followTarget) ?? { x: 0, y: 0, z: 0 }
// Place camera behind Doty in WORLD coordinates:
// (0, +height, -distance) relative to follow's world position.
// (This is robust even if we didn't parent under Doty.)
ecs.Position.set(world, eid, {
x: followPos.x + 0,
y: followPos.y + height,
z: followPos.z - distance,
})
}
const applyYaw = () => {
const { faceTarget } = schemaAttribute.get(eid)
const { yawDeg } = dataAttribute.get(eid)
// Apply camera yaw
const camQuat = ecs.math.quat.yDegrees(yawDeg)
ecs.Quaternion.set(world, eid, { ...camQuat })
// Optionally rotate Doty to face the same yaw (so he faces user's forward)
if (faceTarget) {
const dotyQuat = ecs.math.quat.yDegrees(yawDeg)
ecs.Quaternion.set(world, faceTarget, { ...dotyQuat })
}
}
ecs.defineState('default')
.initial()
.onEnter(() => {
// Reset yaw and snap the camera behind Doty on entry to the map space
dataAttribute.set(eid, { yawDeg: 0 })
snapCameraBehindFollow()
applyYaw()
})
// Keep camera locked behind Doty every frame & maintain yaw
.onTick(() => {
snapCameraBehindFollow()
applyYaw()
})
// Horizontal drag rotates yaw. (No delta multiplier; it's already a delta.)
.listen(world.events.globalId, ecs.input.SCREEN_TOUCH_MOVE, (e) => {
dataAttribute.mutate(eid, (cursor) => {
const { rotationSensitivity } = schemaAttribute.get(eid)
// @ts-ignore
cursor.yawDeg += e.data.change.x * rotationSensitivity
})
})
},
})
I am really new to this and testing things out to see if I can use for a project. I modified the demo project and everything seems to work fine with the exception of this issue, which is a show-stopper after the first location. I tried different browsers, and order of locations. I did notice that when you leave the AR for the map, depending on where you are looking does affect the height you are away from doty when you enter the map.
I am still struggling with the same issue. I also tried the provided script but does not fix the height above Doty after returning to the map view. Every time I go into a AR experience and return to the map I see to be higher above Doty. Surely there is a way to reset the vertical height in World Map Controls? Not sure how this is not a common issue for anyone cloning the scavenger hunt.
I’ve let the engineering team know, there’s something going on with the Map Entity and switching Spaces.
Yeah I have tried everything. Returning to map only resets yaw, but even if I try to reset the height it does not seem to work.
This seems to be fixed now. Thank You
@Richard_Price did this resolved on its own? or did you have a work around or a script that was needed?
It was just working again a day or so after it was passed to engineering team, so I presume it was fixed on the back end. I reverted all the code back to the demo code and works fine now.