Serious Game - Electrónica VR 1.0.0
Loading...
Searching...
No Matches
ExplorerAvatar Class Reference

Conecta el modelo 3D del robot (RobotKyle) al XR rig del Explorador. More...

Inheritance diagram for ExplorerAvatar:
Inheritance graph
Collaboration diagram for ExplorerAvatar:
Collaboration graph

Public Member Functions

void SetHeadVisible (bool visible)
 Activa o desactiva la cabeza en runtime (útil para modo espectador).

Public Attributes

Transform xrCamera
Transform avatarRoot
Animator avatarAnimator
string headBoneName = "head"
bool hideHeadInVR = true
float rotationSmoothing = 10f

Private Member Functions

void Awake ()
void Start ()
void LateUpdate ()
void MoveAvatarToCamera ()
void RotateAvatarToCamera ()
void UpdateAnimation ()
void HideHead ()

Static Private Member Functions

static Transform FindBone (Transform root, string boneName)

Private Attributes

CharacterController _cc
Transform _headBone

Static Private Attributes

static readonly int _animSpeed = Animator.StringToHash("Speed")
static readonly int _animMotion = Animator.StringToHash("MotionSpeed")

Detailed Description

Conecta el modelo 3D del robot (RobotKyle) al XR rig del Explorador.

SETUP en la escena Explorador.unity:

  1. Selecciona el GameObject raíz del Explorador (el que tiene PlayerController).
  2. Arrastra RobotKyle.prefab como hijo de ese GameObject.
  3. Añade este script al mismo raíz del Explorador.
  4. Asigna: xrCamera → la cámara principal del XR Origin (Main Camera) avatarRoot → el transform raíz de RobotKyle (el hijo recién añadido)
  5. headBoneName → "head" (nombre del hueso de la cabeza en RobotKyle)

QUÉ HACE:

  • El cuerpo sigue la posición XZ de la cámara (no el Y, para que no flote).
  • El cuerpo rota hacia donde mira la cámara en el plano horizontal.
  • Oculta el mesh de la cabeza del robot para que no tape el visor VR.
  • Reproduce la animación de caminar/idle según si el CharacterController se mueve.

Member Function Documentation

◆ Awake()

void ExplorerAvatar.Awake ( )
private

◆ FindBone()

Transform ExplorerAvatar.FindBone ( Transform root,
string boneName )
staticprivate

◆ HideHead()

void ExplorerAvatar.HideHead ( )
private

◆ LateUpdate()

void ExplorerAvatar.LateUpdate ( )
private

◆ MoveAvatarToCamera()

void ExplorerAvatar.MoveAvatarToCamera ( )
private

◆ RotateAvatarToCamera()

void ExplorerAvatar.RotateAvatarToCamera ( )
private

◆ SetHeadVisible()

void ExplorerAvatar.SetHeadVisible ( bool visible)

Activa o desactiva la cabeza en runtime (útil para modo espectador).

◆ Start()

void ExplorerAvatar.Start ( )
private

◆ UpdateAnimation()

void ExplorerAvatar.UpdateAnimation ( )
private

Member Data Documentation

◆ _animMotion

readonly int ExplorerAvatar._animMotion = Animator.StringToHash("MotionSpeed")
staticprivate

◆ _animSpeed

readonly int ExplorerAvatar._animSpeed = Animator.StringToHash("Speed")
staticprivate

◆ _cc

CharacterController ExplorerAvatar._cc
private

◆ _headBone

Transform ExplorerAvatar._headBone
private

◆ avatarAnimator

Animator ExplorerAvatar.avatarAnimator

◆ avatarRoot

Transform ExplorerAvatar.avatarRoot

◆ headBoneName

string ExplorerAvatar.headBoneName = "head"

◆ hideHeadInVR

bool ExplorerAvatar.hideHeadInVR = true

◆ rotationSmoothing

float ExplorerAvatar.rotationSmoothing = 10f

◆ xrCamera

Transform ExplorerAvatar.xrCamera

The documentation for this class was generated from the following file: