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 /
This question was closed Aug 14, 2014 at 05:57 AM by tanoshimi for the following reason:

The question is answered, right answer was accepted

avatar image
-1
Question by The_Edster · Aug 13, 2014 at 06:49 PM · c#

Whats wrong with this code? im new

whats wrong with this code? im doing teh roll a ball game project

using UnityEngine; using System.Collections;

public class NewBehaviourScript : MonoBehaviour { void Update () { } void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertial = Input.GetAxis ("Vertical");

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

     rigidbody.AddForce (Vector3);
 }

heres teh compiler errors:

Assets/Scripts/NewBehaviourScript.cs(11,70): error CS0103: The name moveVertical' does not exist in the current context Assets/Scripts/NewBehaviourScript.cs(11,83): error CS1502: The best overloaded method match for UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments

Assets/Scripts/NewBehaviourScript.cs(11,83): error CS1503: Argument #3' cannot convert object' expression to type float' Assets/Scripts/NewBehaviourScript.cs(13,37): error CS0119: Expression denotes a type', where a variable', value' or method group' was expected Assets/Scripts/NewBehaviourScript.cs(13,27): error CS1502: The best overloaded method match for UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3)' has some invalid arguments

Assets/Scripts/NewBehaviourScript.cs(13,27): error CS1503: Argument #1' cannot convert object' expression to type `UnityEngine.Vector3'

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 Exbow · Aug 13, 2014 at 07:10 PM 0
Share

you have made a typo on the initialization "float moveVertial = Input.GetAxis ("Vertical");" i think you meant moveVertical

avatar image christoph_r · Aug 13, 2014 at 07:15 PM 0
Share

Format your code properly. This makes it easier for us to help you. The error seems to be, as Exbow pointed out, that you misspelt moveVertical and so your parameters for your movement vector are off. The other error is that the parameter for AddForce should be movement, not Vector3. Vector3 is a type of variable, movement is an actual variable with a value to assign and handle.

avatar image The_Edster · Aug 13, 2014 at 08:24 PM 0
Share

robertu was right that fixed it

1 Reply

  • Sort: 
avatar image
1

Answer by calmcarrots · Aug 14, 2014 at 05:17 AM

  rigidbody.AddForce (movement);
 
 //Vector3 is a type so you can't add a force to a Vector3. This fixed version is above
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

help my code has error CS8205 :parsing error how can I fix? 2 Answers

Can anyone help me with a simple CSharp error 1 Answer

Error CS8025: Parsing error. HELP! 1 Answer

Help calling a code in C# script 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