Hello! Please tell me, what am I doing wrong?
I do it exactly according to the instructions (DrawRay in Unity) on the network.
There are no errors, the Ray is being created, the RayCast is working, but the Ray is not displayed.
I do it exactly according to the instructions (DrawRay in Unity) on the network.
There are no errors, the Ray is being created, the RayCast is working, but the Ray is not displayed.
C#:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleJSON;
using UnityEngine.UI;
using UnityEngine.XR;
using UnityEngine.Events;
public class RayTriggerAtomTest : MVRScript {
void Update() {
var vStart = new Vector3(
transform.position.x + 2.5f, // offset - because when placing an object at 0,0,0, the "transform.position" returns (-2.5, -1.8, 0)
transform.position.y + 1.8f, // offset - because when placing an object at 0,0,0, the "transform.position" returns (-2.5, -1.8, 0)
transform.position.z);
var vEnd = transform.forward;
// We launch a beam from the center of the object (with this plugin) in the direction of Z-gizmo
Ray ray = new Ray(vStart, vEnd);
// Drawing ray from Start in the direction of Z-gizmo and 10 meters long, Green color
Debug.DrawRay(transform.position, vEnd * 10f, Color.green);
RaycastHit hit;
if ( Physics.Raycast(ray, out hit) ) {
SuperController.LogMessage("hit: " + hit.collider.ToString());
}
}
}
Last edited: