public class Movement : MonoBehaviour
{
private Vector3 mousePosition;
public float moveSpeed = 0.5f;
public bool isMoving = false;
public float dashEndSpeed;
public float lastDash;
public float dashCooldown = 1f;
public float dashTime = 0.2f;
public bool isDashing = false;
public float dashSpeed;
void Update()
{
if (Input.GetMouseButtonDown(1) && isMoving == false)
{
isMoving = true;
}
else if (Input.GetMouseButtonDown(1) && isMoving == true)
{
isMoving = false;
}
if (Input.GetMouseButtonDown(0) && isMoving == false && lastDash < dashCooldown)
{
lastDash = Time.time;
isMoving = true;
dashEndSpeed = moveSpeed;
dashSpeed = dashEndSpeed * 5;
moveSpeed = dashSpeed;
isDashing = true;
do
{
if (moveSpeed = dashSpeed && lastDash < dashTime) //error here
{
isMoving = false;
moveSpeed = dashEndSpeed;
isDashing = false;
}
} while (moveSpeed = dashSpeed); //error here
}
else if (Input.GetMouseButtonDown(0) && isMoving == true && lastDash < dashCooldown)
{
lastDash = Time.time;
dashEndSpeed = moveSpeed;
dashSpeed = dashEndSpeed * 5;
moveSpeed = dashSpeed;
isDashing = true;
do
{
if (moveSpeed = dashSpeed && lastDash < dashTime) //error here
{
isMoving = false;
moveSpeed = dashEndSpeed;
isDashing = false;
}
} while (moveSpeed = dashSpeed); //error here
}
}
void FixedUpdate()
{
if (isMoving == true)
{
mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
transform.position = Vector2.Lerp(transform.position, mousePosition, moveSpeed * Time.deltaTime);
}
}
}
My errors here are where I have marked them with ‘//error here’, and they are as follows:
-
after each marked if statement I receive the message ‘Assets\Scripts\Player\Movement.cs(49,22): error CS0029: Cannot implicitly convert type ‘float’ to ‘bool’’
-
and after each while statement marked, I receive this ’
Assets\Scripts\Player\Movement.cs(42,33): error CS0019: Operator ‘&&’ cannot be applied to operands of type ‘float’ and ‘bool’
’
I’ve been trying for a while to fix this and can’t figure it out, so I figured I’d ask here then go to bed, see what fixes I get in the morning. thanks :).