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 /
avatar image
0
Question by unitynovice5 · Feb 06, 2017 at 08:31 AM · c#error

error CS0103: The name `Cardboard' does not exist in the current context

I'm attempting to make a cardboard game, and I get this error: DogWalkScore.cs(59,69): error CS0103: The name `Cardboard' does not exist in the current context I've scoured the site for a solution, but nothing has worked, I'm still doing something wrong. Thank you in advance, your help is greatly appreciated. The script code is below.

 using System;
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class DogWalkScore : MonoBehaviour
 {
     private const int RIGHT_ANGLE = 90;
     private int score;
 
     public Text scoreText; 
 
     // This variable determinates if the player will move or not 
     private bool isWalking = false;
 
     GvrHead head = null;
 
     //This is the variable for the player speed
     [Tooltip("With this speed the player will move.")]
     public float speed;
 
     [Tooltip("Activate this checkbox if the player shall move when the Cardboard trigger is pulled.")]
     public bool walkWhenTriggered;
 
     [Tooltip("Activate this checkbox if the player shall move when he looks below the threshold.")]
     public bool walkWhenLookDown;
 
     [Tooltip("This has to be an angle from 0° to 90°")]
     public double thresholdAngle;
 
     [Tooltip("Activate this Checkbox if you want to freeze the y-coordiante for the player. " +
              "For example in the case of you have no collider attached to your CardboardMain-GameObject" +
              "and you want to stay in a fixed level.")]
     public bool freezeYPosition;
 
     [Tooltip("This is the fixed y-coordinate.")]
     public float yOffset;
 
     void Start()
     {
         head = Camera.main.GetComponent<StereoController>().Head;
         score = 0;
         SetCountText();
     }
 
     void Update()
     {
         // Walk when the Cardboard Trigger is used 
         if (walkWhenTriggered && !walkWhenLookDown && !isWalking && Cardboard.SDK.Triggered)
         {
             isWalking = true;
         }
         else if (walkWhenTriggered && !walkWhenLookDown && isWalking && Cardboard.SDK.Triggered)
         {
             isWalking = false;
         }
 
         // Walk when player looks below the threshold angle 
         if (walkWhenLookDown && !walkWhenTriggered && !isWalking &&
             head.transform.eulerAngles.x >= thresholdAngle &&
             head.transform.eulerAngles.x <= RIGHT_ANGLE)
         {
             isWalking = true;
         }
         else if (walkWhenLookDown && !walkWhenTriggered && isWalking &&
                  (head.transform.eulerAngles.x <= thresholdAngle ||
                  head.transform.eulerAngles.x >= RIGHT_ANGLE))
         {
             isWalking = false;
         }
 
         // Walk when the Cardboard trigger is used and the player looks down below the threshold angle
         if (walkWhenLookDown && walkWhenTriggered && !isWalking &&
             head.transform.eulerAngles.x >= thresholdAngle &&
             Cardboard.SDK.Triggered &&
             head.transform.eulerAngles.x <= RIGHT_ANGLE)
         {
             isWalking = true;
         }
         else if (walkWhenLookDown && walkWhenTriggered && isWalking &&
                  head.transform.eulerAngles.x >= thresholdAngle &&
                  (Cardboard.SDK.Triggered ||
                  head.transform.eulerAngles.x >= RIGHT_ANGLE))
         {
             isWalking = false;
         }
 
         if (isWalking)
         {
             Vector3 direction = new Vector3(head.transform.forward.x, 0, head.transform.forward.z).normalized * speed * Time.deltaTime;
             Quaternion rotation = Quaternion.Euler(new Vector3(0, -transform.rotation.eulerAngles.y, 0));
             transform.Translate(rotation * direction);
         }
 
         if (freezeYPosition)
         {
             transform.position = new Vector3(transform.position.x, yOffset, transform.position.z);
         }
     }
 
     private void OnTriggerEnter(Collider Rat)
     {
         if (Rat.gameObject.CompareTag("Pickup"))
         {
             Rat.gameObject.SetActive(false);
             score = score + 1;
             SetCountText();
         }
     }
     void SetCountText()
     {
         scoreText.text = "Score: " + score.ToString();
     }
 }
 
Comment
Add comment · Show 2
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
avatar image game4444 · Feb 06, 2017 at 09:51 AM 0
Share

Error shows that editor is unable to find "CardBoard" class which your are accessing. Do you delete something in your project? I think you are getting error On this Line "Cardboard.SD$$anonymous$$.Triggered". Please restore cardboard things, error will be solved.

avatar image MarshallN · Feb 08, 2017 at 09:25 AM 0
Share

In Unity, try Assets -> Reimport All. Cached declarations and references have caused quite a few issues for me in the past.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by unitynovice5 · Feb 07, 2017 at 08:46 AM

I see what you're saying, but I switched from an old version of Cardboard to the current version, and that's when the script stopped working. I have the Cardboard Unity Asset Package installed, it's just not the same one the script was originally written for. :)

Comment
Add comment · Show 1 · 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
avatar image unitynovice5 · Feb 09, 2017 at 05:26 AM 0
Share

No, it's something I pieced together from various tutorials.

avatar image
0

Answer by Pyrotechnic · Feb 07, 2017 at 08:43 AM

Is this the look to walk demo from Nurfacegames?

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

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

not all lines of code running c# 0 Answers

Selecting Object From Top Causes NullReference 1 Answer

error on getint c# 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