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 /
  • Help Room /
avatar image
0
Question by Mezzamozzarella · Apr 12, 2016 at 03:41 PM · 2dmovementcontrollervelocityaddforce

How would i apply instant forces on my player/character for instant change of direction and responsiveness?

EDIT: I'm usinc C# but if you're can answer me only in Java that's okay, ill try to figure out how to do it in C#.

Hey, i'm pretty new to scripting and i'm having some trouble with the movement of my player.

I've been trying to get him to move/change directions(left/Right) instantly but i haven't had any luck, using addforce isn't giving me the instant, responsive change i want and with velocity i managed to come close to what i wanted i don't really want to use velocity because of all the issues it apparently creates with other objects and physics.

Picture below shows what im trying to do, sorry for the bad paint skills but it might make it easier for you guys.

  1. I want my player to start "falling" at a constant speed without accelerating and i'd like to be able to move left and right instantly (Can't figure out how to do that using AddForce), i also want to be able to add a force in the opposite direction to "brake"

  2. I want to have an object pick-up that when picked up instantly ads X amount of speed to my player for a few seconds,

Here is the Picture of what im after in the simplest form i could come up with

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
0

Answer by MelvMay · Apr 12, 2016 at 03:57 PM

Use impulse forces which adds the force to the velocity immediately.

When using Rigidbody or Rigidbody2D 'AddForce' you can specify a ForceMode or ForceMode2D.

You can use Impulse on both 2D & 3D.

On 3D you can also use Velocity Change which adjusts the velocity without the mass.

Really though; all it's doing is taking the current velocity, adding some value to it and then setting it back. You can do this with the Rigidbody/Rigidbody2D.velocity property yourself as well. If you simply write over the velocity ignoring what was in it before then you're stomping on velocity that may have been added to stop a collision or gravity which is why it's bad to do so. It doesn't mean you can't change velocity, just be mindful of how you change it.

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 Mezzamozzarella · Apr 12, 2016 at 04:11 PM 0
Share

Thanks for the suggestions, using impulse and Force sounds good, i wont be having mass or gravity on.

Not sure about how im going to go about the boost pick yet, i guess ill figure it out later.

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

82 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

Related Questions

A 2D Character Controller with Rigidbody2D.AddForce 2 Answers

How do I assign a velocity to an object on only 1 axis? 1 Answer

Trying to add force to an object... is this done correctly? 0 Answers

2D : How to overwrite rigidbody velocity when "skill" input pressed ??? 0 Answers

Using rb.velocity and Add Force on the same gameobject? 0 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