Hello, well I’m new to this forum and didn’t have a clue where to place this post.
I’m currently working on a project with a MS HoloLens in which I place objects in front of the user that he has to collect then. Everything works fine as long as the user is situated in a plane and I can simply use the y coordinate of the camera to make sure the next object is placed in the same height the user is in.
When I then move to a slope and use the same application the object placing in the same height won’t work anymore as it will be placed in the air above the slope unreachable for the user.
Did anyone already work on such a problem or has any clues on how to solve this?
P.S.: I already tried using the Spatial Mapping feature but it’s certainly not realy usable for this use case as the ToF sensor only looks three meters ahead.
Best regards
David
One approach to consider would be to perform a Raycast downward such that it hits the slope. The RaycastHit will give you the Normal vector of the collider at the collision point. You could then place the object at the collision point, and use the normal vector to properly rotate the object so it’s aligned with the slope (if that’s what you want).
I need something like this, yes. The scenario I’m facing is the following (academic use case): Imagine building a helmet with an augmented reality device included. In my case this would be the HoloLens. I now want to use this helmet for skiing and virtually insert objects to collect in my field of view to “learn” skiing. The problem now is that I don’t have any terrain or area cartographed with the HoloLens yet. I’m standing on top of a hill for the first time and want to make sure the objects are placed correctly onto the slope.
Now back to the ray cast idea, and correct me if I’m wrong. If I’ve got the HoloLens on and look at a tree ten meters away and send a ray cast, will it collide with the tree without knowing it’s there? As I understood this the ray cast will only collide with objects that are already recognized by the HoloLens spatial perception.
Also binding the object placement dynamically via ray cast to the user looking somewhere it will just randomly spawn objects whenever the ray cast hits something, no?
I see. I didn’t realize from your original post that by “slope”, you meant a physical slope in the real world (as opposed to a Unity plane object rotated at a certain angle).
You’re right that raycasting will only intersect with colliders within the game, not with any “real” objects the camera picks up, unless you previously mapped colliders to the real objects. I don’t know a thing about AR, and whether the API makes it simple to pick out the structure of the terrain based on parallax or some other technique, but it seems like that kind of behavior might just be built in.
I’ll let someone else chime in here who has actually developed for AR, but my hunch would be that something already exists for converting the real-world view into geometry. I don’t believe that every AR developer has to reinvent the wheel to figure out where all the surfaces are in the world.