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.
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"
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
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.
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
Follow this Question
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