Hello all,
I am quite a newbie in this game developing world but I started a little ski game project
My problem is I am trying to implement input from the controller and starting using the unity input system.
Before that, to make my character spin, I would use :
if (Input.GetKey(KeyCode.LeftArrow))
rb.AddRelativeTorque(-Vector3.up* speedFlip, ForceMode.Impulse);
if (Input.GetKey(KeyCode.RightArrow))
rb.AddRelativeTorque(Vector3.up* speedFlip, ForceMode.Impulse);
and it worked perfectly, I could adjust the force of spinning by changing the value of the float
speedFlip
But now that I am using the unity input system, this speedFlip
variable doesn’t seem to change anything
In fact, the player will spin at the same speed no matter what value I put in speedFlip
…
Here is the code since I implemented the unity input system :
float spin;
void Awake()
{
controls.Air.Spin.performed += ctx => spin = ctx.ReadValue<float>();
controls.Air.Spin.canceled += ctx => spin = 0;
}
void Start()
{
rb = gameObject.GetComponent<Rigidbody>();
}
void Update()
{
//unity input system - to spin
float s = spin * speedFlip;
rb.AddRelativeTorque(s * Vector3.up, ForceMode.Impulse);
Debug.Log(s);
}
As you can see I tried looking at the value of the s variable to see if it was impacted by the speedFlip
float
, and it is so that’s why I don’t understand why the player still spins at the same speed no matter what the speedFlip
value is…
The code I pasted is a simplified version with only the lines that interest us in this case
I can share the full version if any one is interested and can help me out
Thank you in advance