using UnityEngine;
using System.Collections;
public class CharController : MonoBehaviour
{
public float maxSpeed = 10f;
bool facingRight = true;
bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
public float jumpForce = 700f;
void Start ()
{}
void FixedUpdate ()
{
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
float move = Input.GetMouseButtonDown(0);
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
if (move > 0 && !facingRight)
Flip ();
else if(move < 0 && facingRight)
Flip();
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
void Update ()
{
if(grounded && Input.GetKeyDown(KeyCode.Space))
rigidbody2D.AddForce(new Vector2(0, jumpForce));
}
}
I keep getting this error:
Assets/Scripts/CharController.cs(22,23): error CS0029: Cannot implicitly convert type bool' to
float’