void OnButtonDown(byte controller_id, MLInputControllerButton button) { if (button == MLInputControllerButton.Bumper) { if (bubble) { Destroy(bubble); } Debug.Log("Place bubble"); // Create a raycast parameters variable MLWorldRays.QueryParams _raycastParams = new MLWorldRays.QueryParams { // Update the parameters with our Camera's transform Position = Controller.position, Direction = Controller.forward, UpVector = Controller.up, // Provide a size of our raycasting array (1x1) Width = 1, Height = 1 }; // Feed our modified raycast parameters and handler to our raycast request MLWorldRays.GetWorldRays(_raycastParams, HandleOnReceiveRaycast); } }
// Update is called once per frame void Update() { MLWorldRays.QueryParams _raycastParams = new MLWorldRays.QueryParams { Position = cTransform.position, Direction = cTransform.forward, UpVector = cTransform.up, Width = 1, Height = 1 }; MLWorldRays.GetWorldRays(_raycastParams, HandleOnReceiveRaycast); }
// Update is called once per frame void Update() { // Create a raycast parameters variable MLWorldRays.QueryParams _raycastParams = new MLWorldRays.QueryParams { // Update the parameters with our Camera's transform Position = ctransform.position, Direction = ctransform.forward, UpVector = ctransform.up, // Provide a size of our raycasting array (1x1) Width = 1, Height = 1 }; // Feed our modified raycast parameters and handler to our raycast request MLWorldRays.GetWorldRays(_raycastParams, HandleOnReceiveRaycast); }
private void CastRay(Vector3 position, Vector3 direction) { MLWorldRays.QueryParams _raycastParams = new MLWorldRays.QueryParams { // Update the parameters with our Hand's transform Position = position, Direction = direction, UpVector = new Vector3(0, 1, 0), // Provide a size of our raycasting array (1x1) Width = 1, Height = 1 }; // Feed our modified raycast parameters and handler to our raycast request MLWorldRays.GetWorldRays(_raycastParams, HandleOnReceiveRaycast); }
void Awake() { MLResult result = MLWorldRays.Start(); if (!result.IsOk) { Debug.LogError("Error BaseRaycast starting MLWorldRays, disabling script."); enabled = false; return; } var raycastParams = new MLWorldRays.QueryParams(); raycastParams.Position = POSITION; raycastParams.Direction = DIRECTION; MLWorldRays.GetWorldRays(raycastParams, HandleOnReceiveRaycast); }
/// <summary> /// Continuously casts rays using _raycastParams. /// </summary> private void Update() { if (_isReady) { _isReady = false; _raycastParams.Position = Position; _raycastParams.Direction = Direction; _raycastParams.UpVector = Up; _raycastParams.Width = Width; _raycastParams.Height = Height; _raycastParams.HorizontalFovDegrees = HorizontalFovDegrees; _raycastParams.CollideWithUnobserved = CollideWithUnobserved; MLWorldRays.GetWorldRays(_raycastParams, HandleOnReceiveRaycast); } }
void Update() { if (!_iController.Connected) { Debug.Log("Error controller not connected"); return; } float deltaTime = Time.deltaTime; // HANDS var keypose = false; var hand = MLHands.Right; if (hand.KeyPose == H_KEYPOSE && hand.KeyPoseConfidence > H_KEYPOSE_CONFIDENCE_THRESHOLD) { keypose = true; } if (_hFirst) { _hFirst = false; _hLastKeypose = !_hLastKeypose; } if (keypose != _hLastKeypose) { _hLastKeypose = keypose; if (keypose) { _wrChangingHeight = false; gameObject.AddComponent <Rigidbody>(); } else { var rb = GetComponent <Rigidbody>(); if (rb != null) { Destroy(rb); } Vector3 position = transform.position; position.y = _wrBaseHeight; transform.position = position; } } // INPUT if (!_hLastKeypose) { var touch = _iController.State.TouchPosAndForce[I_TOUCH_CONTROL]; var position = transform.position; position.x += I_SPEED_HORZ * touch.x * deltaTime; position.z += I_SPEED_HORZ * touch.y * deltaTime; transform.position = position; } // WORLD RAYS if (!_wrPending && !_hLastKeypose) { _wrPending = true; var raycastParams = new MLWorldRays.QueryParams(); raycastParams.Position = transform.position; raycastParams.Direction = WR_DIRECTION; MLWorldRays.GetWorldRays(raycastParams, HandleOnReceiveRaycast); } if (_wrChangingHeight) { var targetY = _wrLastCentimeters / 100.0f; var position = transform.position; if (position.y <= targetY) { position.y += WR_SPEED_VERT * deltaTime; if (targetY - position.y <= WR_CENTIMETER) { _wrChangingHeight = false; position.y = targetY; } } else { position.y -= WR_SPEED_VERT * deltaTime; if (position.y - targetY <= WR_CENTIMETER) { _wrChangingHeight = false; position.y = targetY; } } transform.position = position; } }