Tutorial / Help for "Adding Scene Reference and Point-At Crosshairs"

I need some help with the crosshair and scene / object understanding. The doc here doesn’t help much:

Is in the sample scenes an area where this feature is explained in detail?
Thanks

Hello @info_AM,

Could you provide more details about the issue you’re experiencing? The more information you share, the better we can assist you!

For me it’s not obvious how this feature works and what I can do with it. So I need a complete tutorial what this is all about.

In the “Convai Demo - All Features” demo I talked to Missy and looked at the tower object. “I asked what is this?”

In my meta Quest MR project I want to have a system where the user can ask “What is this?” when looking at objects I want to be able to interact. I want to implement a system where:

  1. If controller is pointing at an interactable object and I ask “What is this?” the convai NPC needs to react to this.
  2. If no controller is raycasting / active and I ask “What is this?” the gaze (center of screen) is checked and detected if a interatable object is looked at.

How do I have an interactable object and raycast with convai? Is there something “out of the box” or do I need to create everything myself (which I can with tutorials). Just asking if you already have it working and I just can’t find an example.
Thanks

Missy is a demo character for Narrative Design and doesn’t include any scripts related to Actions.

To achieve the functionality you described, follow these steps:

  1. Make sure your scene includes the Convai Essentials Prefab, which already contains the Convai Crosshair Canvas Prefab with the necessary Crosshair Handler script.
  2. Add Convai Actions Handler to your NPC.
  3. Include the Convai Interactables Data Prefab in your scene.
  4. In Convai Interactables Data, set up the Dynamic Move Target Indicator by dragging the prefab from Assets/Convai/Prefabs/Utils/Dynamic Move Target Indicator.prefab into your scene, then reference it in the appropriate field in Interactables Data.

These are the basic requirements.

Next, add an object to your scene (e.g., a Cube) with a Collider.

  • In Interactables Data, go to the Objects section and add a new object.
  • Give it a name, which will define what the object is when the NPC is asked. You can also add a description.
  • Set the reference to the object you just added.

After this setup, when the Crosshair is over the object and you ask the NPC about it, the NPC will be able to identify it.

Additionally, without adding any specific objects, if you look at a floor or ground in your scene and ask the NPC something like “Can you move there?”, the NPC will be able to navigate to that location.

If you need further assistance, feel free to ask.

1 Like

Wow, ok. That seems quite what I want. Nice to see that this is working.
“Only” thing missing is the “controller or gaze” logic. But I guess I have to do that on my own…

What you describe will always take the center of screen (crosshair) to check what is hit, right?

Exactly!

To customize the logic for “controller or gaze,” you just need to modify one part of the code. In ConvaiCrosshairHandler.cs, look for the FindPlayerReferenceObject method.

Specifically, update this line:

if (Physics.Raycast(_camera.ViewportPointToRay(centerOfScreen), out RaycastHit hit))

This currently casts a ray to the center of the screen. You can adjust this to fit your needs, such as using the controller’s raycast or checking where the player’s gaze is pointing.

With this update, you can define how to detect the object based on your preferred input method.

If you need more help, feel free to ask!

1 Like