VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVR_MovementRestrictor.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
5 using AVR;
6 using AVR.Core;
7 using AVR.Core.Attributes;
8 
9 namespace AVR.Motion {
10  [AVR.Core.Attributes.DocumentationUrl("class_a_v_r_1_1_motion_1_1_a_v_r___movement_restrictor.html")]
11  [CreateAssetMenu(fileName = "MovementRestrictor", menuName = "arc-vr/motion/MovementRestrictor", order = 1)]
12  /// <summary>
13  /// When using a MovementProvider, this scriptable object allows you to set rules for which surfaces qualify as valid teleport locations and which dont.
14  /// </summary>
15  public class AVR_MovementRestrictor : ScriptableObject
16  {
17  [Header("Limit by gameObject tag")]
18  public bool limitTPLocation_byTag = false;
19 
20  [ConditionalHideInInspector("limitTPLocation_byTag", true)]
21  public string validTPTag;
22 
23  [Header("Limit by gameObject layer")]
24  public bool limitTPLocation_byLayer = false;
25 
26  [ConditionalHideInInspector("limitTPLocation_byLayer", true)]
27  public LayerMask validTPLayers;
28 
29  [Header("Limit by maximum slope")]
30  public bool limitTPLocation_bySlope = false;
31 
32  [ConditionalHideInInspector("limitTPLocation_bySlope", true)]
33  public float validTPmaxSlope;
34 
35  public bool isValidTpLocation(RaycastHit loc)
36  {
37  if (limitTPLocation_bySlope && Vector3.Angle(Vector3.up, loc.normal) > validTPmaxSlope) return false;
38  if (limitTPLocation_byTag && !loc.collider.gameObject.CompareTag(validTPTag)) return false;
39  if (limitTPLocation_byLayer && (validTPLayers & 1 << loc.collider.gameObject.layer) < 1) return false;
40  return true;
41  }
42  }
43 }
When using a MovementProvider, this scriptable object allows you to set rules for which surfaces qual...
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
Allows for simple hiding of properties in the UnityEditor depending on certain conditions. For instance, in the following example the "type" field will only be displayed in the inspector if the "tracking" field is set to true: