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 Goodmanson · Oct 17, 2016 at 05:01 AM · unity 5javascriptrigidbodyaddforcejavascript-specific

Rigidbody.Addforce not working in Unity 5.4.1

Hello! In my game, I’m trying to get my player to jump, and in past games it’s worked, but for some reason now it just won’t do anything. I don’t get any errors, but whenever I press space, nothing happens. Why is this happening? Is it the version of Unity I’m using (5.4.1), or what? I tried looking at the script reference, but there's not even an example in Javascript. Here’s my code, if that helps:

 #pragma strict
 public var jumpSpeed = 10;
 function FixedUpdate()
  
 {
 if (Input.GetKey(KeyCode.Space))
  
 {
 GetComponent.<Rigidbody>().AddForce(new Vector3(0, jumpSpeed * Time.deltaTime, 0));
 }
 }
Comment
Add comment · Show 1
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 OpenXcell-Studio · Oct 17, 2016 at 06:07 AM 0
Share

have you converted unity 4 project to unity 5 ?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by CubeCrafter360 · Oct 17, 2016 at 07:24 AM

make a public rigid body //call it rb make a public vector 3 // call it force and were you want to use addforce. you do rb.addforce(force);

then in the inspector change the values of the vector 3 and it works

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
0

Answer by CubeCrafter360 · Oct 17, 2016 at 07:24 AM

 public Rigidbody rb;
 public Vector3 force;
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 if (Input.GetKeyDown(KeyCode.Space))
     {
         rb.AddForce(force);
     }
 }

}

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
0

Answer by CubeCrafter360 · Oct 17, 2016 at 07:24 AM

make a public rigidbody and called it rb then make a public vector 3 call it force then do rb.addforce(force) instedad and change the values of the vector 3 in the inspector and add the rigid body to the script

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I add force in the on trigger 1 Answer

How do I add force on an object(with a rigidbody) that I've randomly instantiated along the "Y" axis? 2 Answers

Input.acceleration on sphere with rigidbody(gravity) 1 Answer

Why is rigidbody.AddRelativeTorque not working? 1 Answer

A sphere moved by relativeforce is acting wierd? 2 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