Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by afrospacebuddha · Dec 11, 2015 at 03:18 PM · gyroscopevolumeerror-handling

error's CS0119, CS1502, CS1503

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(think 3d tilt maze where the goal is to limit an object's movement). 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 avariable', value' ormethod 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 convertobject' 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;


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Jessespike · Dec 11, 2015 at 06:11 PM

Missing the "new" keyword before Vector3 inside of Distance. in this line:

  volume=Vector3.Distance(Vector3(Input.gyro.userAcceleration.x,Input.gyro.userAcceleration.y,Input.gyro.userAcceleration.z),Base);

Needs to be:

  volume=Vector3.Distance(new Vector3(Input.gyro.userAcceleration.x,Input.gyro.userAcceleration.y,Input.gyro.userAcceleration.z),Base);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Not sure how to word this question but having issue with mixer and sound clips 1 Answer

Value returns to default upon exiting the game 0 Answers

gyro.userAcceleration slingshot effect prevention? 0 Answers

Problem with swipe and Gyro 0 Answers

Inaccurate rotations with android phone gyroscope 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges