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 dyach3579 · Jul 16, 2018 at 10:56 AM · error messagenot workingstrange

Issues with script in unity 5.4.5p5 and VS 2017

Hi everyone. I'm learning Unity and scripting because i'm completely new to all of it, and currently I'm watching an instructional video and we are building a flappy bird clone, which seems to be pretty common in instructional videos. But I can't seem to get my player to jump with this script, and i get an error message in the unity console. (Error Message: Assets/Scripts/Player.cs(15,34): error CS0118: Player.rigidBody' is a field' but a `type' was expected)

I'm using unity 5.4.5p5 and visual studio 2017. The instructor is using Monodevelop with his 5.2 version of unity, and his works fine. Would it be a problem using 5.4.5p5 with VS 2017? Here's the script, and thank you for any help.

using UnityEngine; using System.Collections;

public class Player : MonoBehaviour {

 [SerializeField] private float jumpForce = 100f;

 private Animator anim;
 private Rigidbody rigidBody;
 private bool jump = false;

 // Use this for initialization
 void Start () {
     anim = GetComponent<Animator>();
     rigidBody = GetComponent<rigidBody>();
 }
 
 // Update is called once per frame
 void Update () {
     
     if (Input.GetMouseButtonDown(0))
     {
         anim.Play("Jump");
         rigidBody.useGravity = true;
         jump = true;
     }
 }

 void FixedUpdate()
 {
     if (jump == true)
     {
         jump = false;
         rigidBody.velocity = new Vector2(0, 0);
         rigidBody.AddRelativeForce(new Vector2(0, jumpForce), ForceMode.Impulse);
     }
     
 }

}

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

Answer by arjun19 · Jul 16, 2018 at 12:09 PM

 GetComponent<rigidBody>()   must be    GetComponent<RigidBody>()

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 dyach3579 · Jul 17, 2018 at 10:31 AM 0
Share

Thank you Argun19 for responding. Unfortunately since I let windows do their usual updates on my PC yesterday, now for some reason Unity won't start. I'll have to figure out whats going on with unity before i can see if that worked.. I appreciate you responding.

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

91 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 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

Rigidbody2D just doesnt work :| 2 Answers

Why isnt my code working? C# [NOOB] 1 Answer

Not booting past the project selection screen 0 Answers

trying to make a projectile move towards mouse position but but im getting an error anyone able to help 1 Answer

I keep getting these two compiler errors when I open Unity, does anyone have a fix for this? 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