Hi there, Im currently adapting my code so that when the player moves the joystick a little bit then the player will move slow but when they push the joystick all the way then they will go to max speed. However i dont really know how to do this… i read it has something to do with “GetAxisRaw” however im all ready doing this. This is the code (c#) for the movement just now which when the player uses the joystick at any force they still move at max speed:
`//Force for x and y values
float forceX = 0f;
float forceY = 0f;
//Vel equals absolute velocity
float vel = Mathf.Abs(myBody.velocity.x);
//H equals moving left/right
float h = Input.GetAxisRaw("Horizontal");
//If h is greator than 0
if(h >0)
{
//if vel is less than maxvelocity
if (vel < maxVelocity)
{
//If player is on the ground
if (grounded)
{
GetComponent<AudioSource>().Play();
//moving along x axis is eqal to moveforce
forceX = moveForce;
print(vel);
}
else
{
//Gives more control in air, force is equal to move force times 1.1
forceX = moveForce * 1.1f;
}
}
Vector3 scale = transform.localScale;
scale.x = 1f;
transform.localScale = scale;
anim.SetBool("DetectiveRun", true);
}
else if(h<0)
{
if (vel < maxVelocity)
{
if (grounded)
{
GetComponent<AudioSource>().Play();
forceX = -moveForce;
print(vel);
}
else
{
forceX = -moveForce * 1.1f;
}
}
Vector3 scale = transform.localScale;
scale.x = -1f;
transform.localScale = scale;
anim.SetBool("DetectiveRun", true);
}
else
{
anim.SetBool("DetectiveRun", false);
}`
``Any help would be great! Thanks!