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 Jan 07, 2017 at 09:33 AM by VikingTheMad for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by VikingTheMad · Sep 22, 2016 at 07:04 PM · 2d-platformer

2D movement script is wrong?

Trying to get movement in a 2D space, using the code below. But No input is moving my player, a rigidbody and box collider are both on.

 using UnityEngine;
 using System.Collections;
 
 public class Player : MonoBehaviour {
 
     public float speed = 50f;
     public float jumpPower = 150f;
 
     public bool grounded;
 
     private Rigidbody2D rb2d;
 
     void Start () {
         rb2d = gameObject.GetComponent<Rigidbody2D>();
     }
     
 
     void Update () {
     
     }
 
     void FixedUpdate(){
         float h = Input.GetAxis("Horizontal");
         rb2d.AddForce((Vector2.right * speed) * h);
 }
 }
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 yasser_kaddoura · Sep 22, 2016 at 07:41 PM 0
Share

$$anonymous$$ake sure that you are using rigidbody2d and boxcollider2d ins$$anonymous$$d the 3d ones.

1 Reply

  • Sort: 
avatar image
0

Answer by tanoshimi · Sep 22, 2016 at 07:05 PM

Because case sensitivity is important. The method is FixedUpdate, not fixedUpdate.

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 VikingTheMad · Sep 22, 2016 at 07:10 PM 0
Share

Yeah, still not working.

avatar image tanoshimi VikingTheMad · Sep 22, 2016 at 07:16 PM 0
Share

And you've attached this to a gameobject in your scene? What value have you set for speed?

avatar image VikingTheMad tanoshimi · Sep 22, 2016 at 07:18 PM 0
Share

Yes, its attached to the player object, speed value of 50.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

2.5D Platformer - Jump Question 1 Answer

The main camera pans up when I press play.Please help. 0 Answers

Line Renderer. How to lock z axis for side scroller? 1 Answer

[2D] Check if player is on the ground 4 Answers

Trouble with Jumping Algorithm 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