Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Keygen91 · Jun 09, 2015 at 01:09 PM · text

Roll a ball tutorial problems ,, i'm a beginner pls help ..

hello i have some small issues with this code ....

using UnityEngine;

using UnityEngine.UI;

using System.Collections;

public class PlayerController : MonoBehaviour {

 public Rigidbody rb;

 public float speed;

 public Text countText; 

 private int count;

 void Start ()

 {
     rb = GetComponent<Rigidbody> ();

     count = 0;

      SetCountText();

 }
 void FixedUpdate()
 {

     float moveHorizaontal = Input.GetAxis ("Horizontal");

     float moveVertical = Input.GetAxis ("Vertical");

     Vector3 movement = new Vector3 (moveHorizaontal, 0.0f, moveVertical);

     rb.AddForce (movement * speed *Time.deltaTime);    
 }

 void OnTriggerEnter(Collider other)

 {

     if (other.gameObject.CompareTag("Pickup"))

     {
         other.gameObject.SetActive(false);

         count=count+1;

          SetcountText();

}
}

 void SetcountText();

 {
 countText.text="count: " + count.ToString();

 }}





Errors ...

1)Assets/_scripts/PlayerController.cs(34,9): error CS1519: Unexpected symbol {' in class, struct, or interface member declaration 2)Assets/_scripts/PlayerController.cs(35,23): error CS1519: Unexpected symbol =' in class, struct, or interface member declaration

3)Assets/_scripts/PlayerController.cs(35,50): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration

Pls help me out i can't figure out what is it !! :(

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by saravanan-P · Jun 11, 2015 at 08:50 AM

u should insert something in countText...

like this for example,alt text


pc.png (15.7 kB)
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
avatar image
1

Answer by tanoshimi · Jun 09, 2015 at 01:11 PM

 void SetcountText();

Don't put a semicolon after a method signature.

Comment
Add comment · Show 3 · 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 Keygen91 · Jun 10, 2015 at 08:59 AM 0
Share

ok didn't see that ;) now it works like a code,but the game stops every time i collect a pickup object... it'says like this ----NullReferenceException: Object reference not set to an instance of an object PlayerController.SetcountText () (at Assets/_scripts/PlayerController.cs:35) PlayerController.Start () (at Assets/_scripts/PlayerController.cs:14)

avatar image Geva93 · Jun 10, 2015 at 03:38 PM 1
Share

drag and drop your text object to your public CountText in the inspector.

avatar image Keygen91 · Jun 12, 2015 at 08:51 AM 0
Share

i added the player object ,,

avatar image
0

Answer by Keygen91 · Jun 12, 2015 at 10:44 AM

thanks bro ,, i resolved ...i'm new to unity (just 1 week) and i'll post a lot of stupid questions ... but 1 day i'll help you all :)

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

Help with making a triggered gui message 1 Answer

Break the limits on text area 0 Answers

Unity crashes at writing TextMesh? 0 Answers

The variable m_Font of 'GUISkin' doesn't exist anymore 1 Answer

How to save info and display in a textfield 1 Answer


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