-2

I am making an android game where the player must tilt their phone to keep the in-game platform balanced as objects fall on it. I am trying to use music volume as a way to tell the player how close the platform is to being in balance. I am attempting to equate the volume to the distance from the center of the platform to vector3 point made from the x,y,and z components of the gyroscope's attitude.

The errors are:

Assets/balance.cs(27,41): error CS0119: Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected

Assets/balance.cs(27,32): error CS1502: The best overloaded method match for 'UnityEngine.Vector3.Distance(UnityEngine.Vector3, UnityEngine.Vector3)' has some invalid arguments

Assets/balance.cs(27,32): error CS1503: Argument '#1' cannot convert 'object' expression to type 'UnityEngine.Vector3'

I have a guess at why I am getting these errors but don't really understand. For the 1st error I am assuming the Base variable didn't actually get assigned a particular value, and is seen as a type instead of a variable. My guess is that the second and 3rd errors occur when I am taking the variables from the gyroscope quaternion and trying to make a vector3 out of them. Can anyone help me? Thank ya!

using UnityEngine;
using System.Collections;



public class balance : MonoBehaviour {
    //been switching between torque and force with my code to see what works
    public float Force; 
    public float torque;
    public Rigidbody rb;
    private Vector3 prefFrameRotation;
    private Vector3 deltaRotation;
    public float volume;
    public GameObject BalanceBoard=GameObject.Find("BalanceBoard");
    private Vector3 Base;

void Start() {

    Input.gyro.enabled = true;


    deltaRotation = Vector3.zero;
    rb = GetComponent<Rigidbody>();
    }
    void FixedUpdate() {
    //had to make the Base variable because I couldnt just do "BalanceBoard.transform.position" as the second volume argument
    Base = BalanceBoard.transform.position;
     volume=Vector3.Distance(Vector3(Input.gyro.userAcceleration.x,Input.gyro.userAcceleration.y,Input.gyro.userAcceleration.z),Base);
    deltaRotation.x = prefFrameRotation.x - Input.gyro.userAcceleration.x;
    deltaRotation.y = prefFrameRotation.y - Input.gyro.userAcceleration.y;
    deltaRotation.z = prefFrameRotation.z - Input.gyro.userAcceleration.z;
    rb.transform.Rotate(Input.gyro.attitude.x*Force, 0, Input.gyro.attitude.z*Force);
    prefFrameRotation.x = Input.gyro.attitude.x;
    prefFrameRotation.y = Input.gyro.attitude.y;
    prefFrameRotation.z = Input.gyro.attitude.z;
Nika Kasradze
  • 2,834
  • 3
  • 25
  • 48

1 Answers1

2

Base is a reserved keyword in C#. Rename your variable.

Nika Kasradze
  • 2,834
  • 3
  • 25
  • 48