Terminal velocity on x and y axis is higher than normal when force is applied to both axis simultaneously.
Hello there everyone, I am fairly new to this and I've been trying to find a solution to a problem I have but to no avail. I hope my formatting doesn't make you want to scratch your eyes out.
The terminal velocity of a Rigidbody2D (and acceleration) on the X and Y axis when I use the "add.force" to the X and y axis simultaneously is significantly higher than when I use the "add.force" on each axis individually.
Here's the code:
void Update()
{
if (Input.GetKey("space"))
{
yforce = 1f * ymultiplier;
XYforce = new Vector2(xforce * Time.deltaTime, yforce * Time.deltaTime);
rbs.AddForce(XYforce, ForceMode2D.Impulse);
}
else yforce = 0f;
XYforce = new Vector2(xforce * Time.deltaTime, yforce * Time.deltaTime);
if (Input.GetKey("d"))
{
xforce = 1f* xmultiplier;
Debug.Log("X=20");
XYforce = new Vector2(xforce*Time.deltaTime, yforce * Time.deltaTime);
rbs.AddForce(XYforce, ForceMode2D.Impulse);
}
else if (Input.GetKeyUp("d"))
{
xforce = 0f;
Debug.Log("X=0d");
XYforce = new Vector2(xforce * Time.deltaTime, yforce * Time.deltaTime);
}
if (Input.GetKey("a"))
{
xforce = -1f * xmultiplier;
XYforce = new Vector2(xforce * Time.deltaTime, yforce * Time.deltaTime);
rbs.AddForce(XYforce, ForceMode2D.Impulse);
}
else if (Input.GetKeyUp("a"))
{
xforce = 0f;
Debug.Log("X=0a");
XYforce = new Vector2(xforce * Time.deltaTime, yforce * Time.deltaTime);
}
}
Terminal velocity for X and Y when force is applied to each individually
Terminal velocity for X and Y when force is applied to both simultaneously
Your answer
Follow this Question
Related Questions
How do I ignore gravity when using Rigidbody and always have the same jump force? 1 Answer
Trying to add force to an object... is this done correctly? 0 Answers
How to set rigidbody velocity and angularVelocity to Vector3.zero over time? 1 Answer
Keep gravity while adding velocity to a Rigidbody? 1 Answer
RigidBody2D.AddForce() horizontally is not working! 2 Answers