So, I finished the course. For all intents and purposes I learned the material, and can definitely move on to the next section, but I DO have an odd issue that I’m curious about finding a solution to, in case I run into similar issues post-project in future endeavors; In both my code, and in the inspector, my torque is set to 2.5. While playing in Unity, the character can complete 3-4 rotations on a large jump due to torque speed. However, once I build my project out and open it outside of Unity, the torque is DRASTICALLY reduced, to where I can complete 1, MAYBE 2 rotations on a large jump. Due to the differing number of rotations off of the same jump, I know that it isn’t a latency issue, and both my code and inspector values match, so what gives?
The code in question:
public class PlayerController : MonoBehaviour
{
[SerializeField] float torqueAmount = 2.5f;
[SerializeField] float boostSpeed = 30f;
[SerializeField] float baseSpeed = 20f;
Rigidbody2D rb2d;
SurfaceEffector2D surfaceEffector2D;
bool canMove = true;
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
surfaceEffector2D = FindObjectOfType<SurfaceEffector2D>();
}
void Update()
{
if (canMove)
RotatePlayer();
RespondToBoost();
}
public void DisableControls()
{
canMove = false;
}
void RespondToBoost()
{
if (Input.GetKey(KeyCode.W))
{
surfaceEffector2D.speed = boostSpeed;
}
else
{
surfaceEffector2D.speed = baseSpeed;
}
}
void RotatePlayer()
{
if (Input.GetKey(KeyCode.A))
{
rb2d.AddTorque(torqueAmount);
}
else if (Input.GetKey(KeyCode.D))
{
rb2d.AddTorque(-torqueAmount);
}
}
}
Thank you for any information.