Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Which Activation Strategy To Use For Targeted Objects In a VR Street Scene?

Discussion in 'AR/VR (XR) Discussion' started by Orions100, May 8, 2019.

  1. Orions100

    Orions100

    Joined:
    Feb 11, 2019
    Posts:
    8
    I'm a beginner. And I don't know which of the numerous methods for initiating events in a game would be best for my project. So a word from the wise could save me months of splashing around in the water.
    I want to allow a player to step through a sidewalk scene using a first person character controller. And whenever any of a set of targeted objects enters his/her limited field of view, an animation that is associated with that object(s) is played.
    For example: If the person simply passes a store and the object peripherally enters the scene, then nothing happens. But if he turns his head towards the store's window, and a targeted object comes within that tighter field of view, then the associated animation begins.
    Another example: The person can simply walk past a silent dog on the sidewalk. But if he turns his head slightly to look at the dog, it barks.

    A Raycast seems too limited/precise. (The targeted objects would have to pass through the center of the scene in order to trigger the associated animations.)

    Can (should) a "detection radius" be associated with the first person character instead?

    Here's a link to an game example using a "detection radius." But I haven't found the associated code.
    https://unity3d.com/learn/tutorials/projects/3d-game-kit/enemies-3d-game-kit?playlist=51061

    Any other suggested strategies and/or code examples?


    Thanks
     
  2. Orions100

    Orions100

    Joined:
    Feb 11, 2019
    Posts:
    8
    (Continuing)

    Can a second camera (or a non-visible collision object) with a smaller frustrum be associated with the first person character and used to detect collisions with the targeted objects?
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I would probably just compute the angle between the vector to the target, and the camera's forward vector. When that angle is less than some threshold (20 degrees or whatever you choose), start the animation.