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 /
This question was closed Sep 07, 2017 at 04:43 PM by poodn for the following reason:

problem was a simple fix of ctrl+c and ctrl+v

avatar image
0
Question by poodn · Sep 01, 2017 at 04:06 PM · movement scriptnot workingtutorialroll a ball

rollaball ball wont move

already consulted several posts on here, none work here's my script

using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour {

 public float speed;

 private Rigidbody rb;

 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }

 void FixedUpdate ()
 {
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");

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

     rb.AddForce(movement * speed);
 }

}

Comment
Add comment · Show 3
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 poodn · Sep 01, 2017 at 04:36 PM 0
Share

using UnityEngine; using System.Collections;

public class PlayerController : $$anonymous$$onoBehaviour {

 public float speed;

 private Rigidbody rb;

 speed = 1.0f;

 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }

 void FixedUpdate()
 {
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");

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

     rb.AddForce(movement * speed);
 }

}

currently looks like this error reads "Assets/script/playermovement.cs(4,14): error CS0101: The namespace global::' already contains a definition for PlayerController' "

avatar image GuiDroid poodn · Sep 04, 2017 at 10:43 AM 0
Share

Then it's easy, just change the name of the script and class, for example PlayerController2

public class PlayerController2 : $$anonymous$$onoBehaviour

Edit: the name of the script has to be the same as the class name, according to the error, the script is called playermovement.cs ins$$anonymous$$d of PlayerController.cs

avatar image poodn GuiDroid · Sep 05, 2017 at 03:28 PM 0
Share

Assets/script/playermovement.cs(9,11): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration

2 Replies

  • Sort: 
avatar image
1

Answer by GuiDroid · Sep 01, 2017 at 04:19 PM

Has @haruna9x said, you need to set the speed value to anything higher than 0. Either go to the inspector and change it, or change it in the code, such as

 void Start ()
 {
      rb = GetComponent<Rigidbody>();
      speed = 1.0f;
 }
Comment
Add comment · Show 9 · 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 poodn · Sep 01, 2017 at 04:34 PM 0
Share

speed will not show up in the inspector

avatar image poodn · Sep 01, 2017 at 04:57 PM 0
Share

its saying that speed doesnt exist in the current context?

avatar image john-essy · Sep 05, 2017 at 03:48 PM 0
Share

In that case you must be spelling it wrong.

avatar image poodn john-essy · Sep 05, 2017 at 04:00 PM 0
Share

hm... okay, ill try that

avatar image poodn poodn · Sep 05, 2017 at 04:01 PM 0
Share

fixed one error, now its saying that i cant use the "="

avatar image john-essy · Sep 05, 2017 at 08:03 PM 0
Share

Post your code please.

avatar image poodn john-essy · Sep 07, 2017 at 03:22 PM 0
Share

using UnityEngine; using System.Collections;

public class playermovement : $$anonymous$$onoBehaviour {

 public float speed;

 speed = 1.0f

 private Rigidbody rb;

 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }

 void FixedUpdate()
 {
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");

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

     rb.AddForce(movement * speed);
 }

}

avatar image Zyriab poodn · Sep 07, 2017 at 04:27 PM 0
Share

You forgot a semicolon: speed = 1f;.

Show more comments
avatar image
1

Answer by poodn · Sep 07, 2017 at 03:34 PM

problem fixed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

Follow this Question

Answers Answers and Comments

74 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Roll-A-Ball Tutorial: Ball moves on its own 3 Answers

Error when I try to run the build in tutorial (roll a ball, tanks, and etc.) 0 Answers

Roll a Ball Tutorial problem 1 Answer

Roll-a-ball tutorial weird shadows 0 Answers

Roll a Ball Tutorial does not work. Help? 3 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