Question by
gustavodiniz-b · Apr 25, 2018 at 05:45 PM ·
scripting problem2d gameunexpected-symbol
IsTouchingLayers dont work :
can someone help me?? here is my code // Use this for initialization
private Rigidbody2D body = null;
public float runSpeed = 10;
public CircleCollider2D foot;
public LayerMask ground;
public float jumpForce = 20;
public static bool IsTouchingLayers(Collider2D collider, int layerMask = Physics2D.AllLayers);
void Start() {
GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update() {
GetFowardInput();
GetJumpInput();
}
private void GetJumpInput()
{
if (Input.GetButtonDown("Jump") && foot IsTouchingLayers(ground)) {
body.AddForce(Vector2.up * jumpForce);
}
}
private void GetFowardInput()
{
body.velocity = new Vector2(Input.GetAxis("Horizontal") * runSpeed, body.velocity.y);
}
}
Comment