2 Replies - 205 Views - Last Post: 22 June 2019 - 07:58 AM Rate Topic: -----

#1 WilliamRos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-June 19

Need Help with Error (Unity 2018) (error CS0131)

Posted 22 June 2019 - 06:48 AM

[public class PlayerController : MonoBehaviour
{
    public float jumpForce;

    private Rigidbody2D rb;

    private bool isGrounded;
    public Transform groundCheck;
    public float checkRadius;
    public LayerMask whatIsGround;

    private int extraJumps;
    public int extraJumpValue;

    void Start()
    {
        extraJumps = extraJumpValue;
        rb = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        if (isGrounded == true)
        {
            extraJumps = extraJumpValue;
        }

        if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps > 0)
        {
            rb.velocity = Vector2.up * jumpForce;
            extraJumps--;
        } else if(Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded = true)
        {
            rb.velocity = Vector2.up * jumpForce;
        }
    }

    void FixedUpdate()
    {
        isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
        
    }
]
:code:



Hi, I'm new to this and I cant find how to fix this error: error CS0131: The left-hand side of an assignment must be a variable, property or indexer

It

This post has been edited by modi123_1: 22 June 2019 - 07:56 AM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: Need Help with Error (Unity 2018) (error CS0131)

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3825
  • View blog
  • Posts: 13,933
  • Joined: 08-August 08

Re: Need Help with Error (Unity 2018) (error CS0131)

Posted 22 June 2019 - 07:47 AM

Is that C++ or C? It looks like Java to me.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15226
  • View blog
  • Posts: 60,944
  • Joined: 12-June 08

Re: Need Help with Error (Unity 2018) (error CS0131)

Posted 22 June 2019 - 07:58 AM

If it is unity, more like c#.

Not knowing the line, I would think this is causing an issue.

Evaluation is == and assignment is = . Fix the 'isgorunded = true' part.
32	        } else if(Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded = true)

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1