How to create directional drag in Unity? - unity3d

I'm developing a game in which you race in ships that are hovering above the ground. The problem is that they are really difficult to control because the have no friction other than the drag i set in Rigidbody component. Because of that steering is very unresponsive. Setting drag to really high values helps but it works in all directions and thats not what I want. The solution would be making the drag work only sideways so steering is easier, but going forward and backward is normal. Do you know how can I achieve this?

What's your code? Are you adding force by using rigidbody.AddForce? You know that it accepts a second parameter ForceMode.
For example:
rigidbody.addForce(Vector3.up, ForceMode.VelocityChange)
This wil add an instant force, ignoring it's mass. To see other ForceModes, look here :)

Related

How to link rigidbodies with joints while ignoring the other one's drag

I have two rigidbodies. One has 0 drag and gravity is activated, the other one has 10 drag and gravity de-activated. I hoped that since they were connected, the gravity would be applied like there was 0 drag on it, but that is not the case. It still slows down like it did at 10 when it had gravity. I kind of understand why this would happen. I assume it is because it just transfers force to the other object, so drag still acts upon it.
I also tried parenting one rigidbody to the other rigidbody, and that did not work.
Does anyone know how to connect rigidbodies to apply gravity without drag being included. It doesn't matter if it is in script or not. Thanks!
Never mind, I fixed it. A very specific problem, so I won't post my answer, unless you ask.

How to create a physics material with specific friction for the character to fall over faster?

I am making a 2.5d platformer with a pill as a character, which has a very specific movement. Instead of freezing its z rotation so it won't fall over, the pill tumbles over on and on.
So, the problem is that when I put a maxfriction physics material on the pill, it tumbles over great but the gravity when you let go of the move key is extremely slow which is pretty annoying.
However, when I assign a nofriction material on it, it doesn't rotate at all.
Does anyone know how to fix this problem, I know it is very specific, but I am a beginner in unity and I have no idea how to fix this.
Thank you! Emiel

How to make an object bend in the opposite direction as it moves into Unity

I need to move a 3D object like in the "Run sausage" game.
https://www.youtube.com/watch?v=CQa5PUlSfwk
There, as the character runs forward, its body kind of bends backwards, in the direction opposite to the movement.
In particular I do a simulation of a tornado in Unity, but when I want to go forward to the upper part of the tornado moved back, and after 1 second reaches the lower part ("legs")
Any suggestions would help me. Thank you
The movement like in the Sausage Run game can be achieved easily by using animator controller specifically Blend Tree. Watch this tutorial is you are not already familiar with these
https://www.youtube.com/watch?v=E-zQw4GabKw

How can I implement input movement?

I am new to UE and trying to make very simple game to learn the engine.
This is how the game looks
I want the player to be able to move the cube(PlayerPawn) left and right only.
This is my script to move the pawn.
But when I go left or right it also rotates. How can I fix this? How can I implement input movement while the pawn simulates physics?
You're applying floating pawn movement on a non floating object? That just doesn't seem right does it?
If you want to use custom movement just setup a collision component (BoxComponent in your case maybe?) And apply forced with SetForce/AddImpulse or SetLinearVelocity.
Also might be worth your time looking into the Character blueprint clasd that comes with lot's of premade movement capabilities

How to ensure sprites face the correct direction at all times in a 2D top down game. (logic)

I am making a multiplayer top down 2D game with 3d elements. All my movement, healthbars and basic functionality is working flawlessly even while hosted and playing on a server, node.js socket.io. However In this game it is possible to move the camera like in Realm of the mad god.
in case you are in doubt here is a video: https://youtu.be/4tdcxl3aZ0c?t=31s
This of course means that the players can end up being upside down with regards to each other and I cannot find a solution that works in all regards to make sure the sprites of the other players are always facing the correct direction with regards to their movement.
I have made several solution to this problem which cover most scenarios but while play testing other things we always end up noticing that the sprites sometimes face the wrong directions. So I am wondering if anyone has an answer, the logic, the fixing this problem.
Things I have tried:
Adding a gameobject to the camera to which all sprites asses their change in distance and determine their facing direction based off that information. (this leads to the players sometimes flipping erratically when the camera is moved and they as well are moving as sometimes they may be moving slower and there although moving left the camera approaches from the right and that flips them)
Adding a gameobject to the world which allows all sprites to have a fixed point to which they can measure their change in distance and therefore also know what direction to face (this worked somewhat better as they always know what direction they have to face, however once the player is upside down everything is inverted)
Emitting to the other players wether I am upside down or not in order to try to reinvert the above solution in the case I am upside down. (I could not find a good way to do this, and it got me thinking that this must be a problem people have fixed before many times and perhaps someone know of a good solution that works.)
thank you all for your input.
I seem to have found a solution for this issue that works decently well. Keeping in mind that I do not want to have the server being involved in this and I would rather have each individual sprite know its direction rather that have something heavy trying to determine this logic I came up with the following solution. May not be the best but it works. Still very keen to hear other solutions.
On my main character I have a switch case, which changes depending on the players rotation in the world. I need this switch case anyway for fixing (http://answers.unity3d.com/questions/1348301/trying-to-change-the-cameratransparencysortaxis-to.html?childToView=1348316#answer-1348316) that issue.
As the cases change I simply place the gameobject that I want the sprites to compare their distance to at 1 of 4 positions. YPos, YNeg, XPos, XNeg. Meaning that the sprite now determines its facing direction based on a gameobject that is placed in accordance with the Players position. without having to place it on the camera.
I will update if during further play tests this gives me trouble but thus far it works in the all the cases I need it to.
Still very willing to hear other solutions to this problem.
Thank you.