Reputation: 11
I tried to make a platformer game but when i created the fall animation it showed me this error CS1026 at : if(Player, whatIsGround == 0){
This is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterAnim : MonoBehaviour {
private Animator anim;
public LayerMask whatIsGround;
public float Player;
void Start(){
anim = GetComponent<Animator>();
}
void Update(){
if(Player, whatIsGround == 0){
anim.SetBool("Test", true);
} else {
anim.SetBool("Test", false);
}
if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.LeftArrow)){
anim.SetBool("Left", true);
} else {
anim.SetBool("Left", false);
}
if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow)){
anim.SetBool("Right", true);
} else {
anim.SetBool("Right", false);
}
if(Input.GetKeyDown(KeyCode.UpArrow)){
anim.SetTrigger("Jump");
}
}
}
How can i resolve it ?
Upvotes: 0
Views: 70
Reputation: 385
According to the microsoft documentation (link):
Compiler Error CS1026
) expected
An incomplete statement was found.
You have 2 mistakes here. First of all you can't convert float to bool like this and then you can't have ',' symbol between 2 statements in if structure.
I suggest to replace ',' with '&&' or '||' (C# operators) and make boolean expression with Player variable like this:
if(Player > 0 && whatIsGround == 0)
Upvotes: 1