Hi,
To get the example to work I had to write
if(Input.GetKey(KeyCode.LeftArrow))
{
rb2d.AddTorque(torqueAmount = torqueAmount + 1f);
}
else if(Input.GetKey(KeyCode.RightArrow))
{
rb2d.AddTorque(torqueAmount = torqueAmount - 1f);
}
instead of
if(Input.GetKey(KeyCode.LeftArrow))
{
rb2d.AddTorque(torqueAmount);
}
else if(Input.GetKey(KeyCode.RightArrow))
{
rb2d.AddTorque(-torqueAmount);
}
I am wondering that what I have done wrong or what is the concept I have not understood?