How to solve tge 'An object references is required for the non-static field, method, or poroperty' with the GvrBasePointer.LineEndPoint?
I'm new at Unity (and VR) and I'm making a VR game with the GoogleCardboard API and I'm trying to that when the user gaze an object, it can be attach to the GvrReticle so that can move it at will. I found a way to do it by GvrBasePointer.LineEndPoint, but when it compiles it appears the CS0120 error. Here's the code :
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems;
public class cambio : MonoBehaviour {
float distance = 10;
public Rigidbody rb;
public Vector3 teleportPoint;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
}
public void cambiaColor()
{
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
}
public void regreso()
{
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
public void mover()
{
rb.GetComponent<Renderer>().material.color = Color.green;
Vector3 LineEndPoint = new Vector3(GvrBasePointer.LineEndPoint.x, GvrBasePointer.LineEndPoint.y, distance);
Vector3 objPosition = Camera.main.ScreenToWorldPoint(LineEndPoint);
transform.position = objPosition;
//transform.position = new Vector3(transform.position.x+5, transform.position.y, transform.position.z);
}
}
I would like a way to solve this problem or even another way to achive what I want to do.
Your answer
![](https://koobas.hobune.stream/wayback/20220612124434im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Oculus Player Controller does not stick to its predefined animation path 0 Answers
Does the Steam store support Open VR without SteamVR components? 0 Answers
Carried object through terrain 0 Answers
Steam VR HTC Vive: When I change scenes, the Vive controller is no longer tracking positions. 1 Answer
Rotating & fixing the position of an object to one spot 1 Answer