Question by
donpatobill · Aug 26, 2015 at 07:16 AM ·
symbol
unexpected symbol &&
using UnityEngine; using System.Collections;
public class controladorpersonaje : MonoBehaviour {
public float fuerzaSalto = 100f;
public bool isgrounded = true;
public Transform comprobadorSuelo;
public LayerMask mascaraSuelo;
private bool dobleSalto = false;
// Use this for initialization
void Start () {
}
void FixedUpdate(){
isgrounded = Physics2D.OverlapCircle (comprobadorSuelo.position,1, mascaraSuelo);
if (enSuelo) {
dobleSalto = false;
}
}
// Update is called once per frame
void Update () {
if (isgrounded || !dobleSalto) && Input.GetMouseButtonDown (0)) {
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, fuerzaSalto));
if(!dobleSalto && !enSuelo){
dobleSalto = true;
}
}
}
}
Assets/scripts/controladorpersonaje.cs(27,49): error CS1525: Unexpected symbol `&&'
....why i receive this fail?? thx
Comment
Best Answer
Answer by fafase · Aug 26, 2015 at 07:22 AM
if (isgrounded || !dobleSalto) && Input.GetMouseButtonDown (0)) {
you should have an extra parenthesis at the beginning since you check isgrounded AND !doblesalto. Then you close which closes the if statement and then comes the rest.
It should be:
if ((isgrounded || !dobleSalto) && Input.GetMouseButtonDown (0)) {
also ensuelo does not appear in your code. You are using it but it is not declared anywhere.
Answer by donpatobill · Aug 26, 2015 at 05:59 PM
a point for u and u're the best mate , thx so rly much