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 /
avatar image
0
Question by ALKIN1511 · May 09, 2014 at 11:02 PM · rigidbody2daddforce

rigidbody2d addforce for moving gameObject not work

Hi everyone. My english is bad, but I will try to tell you about my problem. Code (C#):

 void FixedUpdate () {
         on_tram = Physics2D.Linecast (on_tram_left.position, on_tram_right.position, 1<< LayerMask.NameToLayer("player_l"));
         Debug.DrawLine (on_tram_left.position, on_tram_right.position, Color.green);
         if(on_tram == true){
             on_tram = false;
             player_tram.rigidbody2D.velocity = Vector2.zero;
             player_tram.rigidbody2D.angularVelocity = 0f;
             Vector2 dir = (tram_vec.transform.position - player_tram.transform.position).normalized;
             Debug.Log(dir);
             player_tram.rigidbody2D.AddForce(dir*500f);
             Debug.DrawLine(player_tram.transform.position, tram_vec.transform.position, Color.green);
                       
         }
     }

So. When game in process and when player cross the line, player not "flying" to gameObject. It make small step in right/left side in moment and after that make ideal vertical jump. And I think player must "fly" for diagonal, but it move very strange. Help me please. You my last hope

Comment
Add comment · Show 5
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 ReContraChanfle · May 09, 2014 at 11:31 PM 0
Share

Better use raycast for line interception, Try with that

avatar image Jojo B · May 09, 2014 at 11:32 PM 0
Share

are you getting an error message or is it just not working the way you want?

avatar image ALKIN1511 · May 10, 2014 at 08:20 AM 0
Share

No, i don't have error message. Its not working like I want.

Ok. I will try with raycast and will write after that!

avatar image ALKIN1511 · May 10, 2014 at 12:00 PM 0
Share

No. Raycast not help. He push my player in SPAAAACE like spaceship

avatar image ALKIN1511 · May 11, 2014 at 05:53 PM 0
Share

Agreed. I'm stupid. I wrote limiter of X coor for player, if player speed $$anonymous$$ORE than limit. Thanks for all

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

add force on topdown bullet 1 Answer

rigidbody2d.addforce for is not working for the x axis 0 Answers

AddForce knockback x axis according to mouse.position more then y axis (2D game) 0 Answers

Rigidbody2d.AddForce behaving odd 1 Answer

Rigidbody2d addforce is weaker at a higher y position. 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