Please Help Need Fix!!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayercontrollerScript : MonoBehaviour
{

private float movementInputDirection;

private bool isFacingRight = true;
private bool IsWalking;

private Rigidbody2D rb;
private Animator anim;

public float movementSpeed = 2f;
public float JumpForce = 5.0f;

// Start is called before the first frame update
void Start()
{
rb = GetComponent();
anim = GetComponent();
}

// Update is called once per frame
void Update()
{
CheckInput();
CheckMovementDirection();
UpdateAnimations();
}

private void FixedUpdate()
{
ApplyMovement();
}

if(rb.velocity.x != 0))
{
IsWalking = true;
}
{
IsWalking = false;
}

private void UpdateAnimations();

private void CheckMovementDirection()

{
if(isFacingRight && movementInputDirection < 0)
{
Flip();
}
else if(!isFacingRight && movementInputDirection > 0)
{
Flip();
}
}
private void CheckInput()
{
movementInputDirection = Input.GetAxisRaw(“Horizontal”);

if (Input.GetButtonDown(“Jump”))
{
Jump();
}

}
private void Jump()
{
rb.velocity = new Vector2(rb.velocity.x, JumpForce);
}

private void ApplyMovement()
{
rb.velocity = new Vector2(movementSpeed * movementInputDirection,rb.velocity.y);
}

private void Flip()
{
isFacingRight = !isFacingRight;
transform.Rotate(0.0f, 180.0f, 0.0f);
}
}

What is your question? I believe I recognize the code, if you do a Google search for the exact error that you are receiving (rb related?), you’ll likely find the answer :slight_smile:

1 Like

If you refuse to state the problem, no one can tell you how to fix it.

Also: Using code tags properly

1 Like

Why do you have a semi-colon right after the declaration of UpdateAnimations()?

I might guess that is the next step in the tutorial :slight_smile: However I suspect they are getting this error: https://discussions.unity.com/t/575504

Sorry i just need someone to fix it there is no certain error i am sorry for not specifying

i am just looking for someone to fix the script mainly i want the walk animation to differ from idle sorry

error cs0106
is the error

The code is gibberish and garbage cut and paste. The first thing you need to do is learn formatting and indentation. Yes, it matters. Because it shows you where the problem is. You know where a piece of code belongs.

This person gave you a pretty strong hint.

Another person asked you to format it.

You didn’t do either and if you won’t, we can’t help you.

it says ; expected at that point in time

it says ; expected also i am new to this sorry

No need to apologise or worry but the fundamentals of learning to code is getting the formatting, particularly the indentation right. Everyone new to this skips that part and thinks it’s not important.

But the indentation tells you what code operates in what “scope” - you’ll get it but it’s like having map handy to work out mistakes… :slight_smile:

Probably because there is no instructions in UpdateAnimations().

@siwoodfull You are missing code there:

private void UpdateAnimations()
{
    DoSomething();
}
2 Likes

Yeah I was trying to nudge them in the right direction but it’s very clear now they need way more than just hints.

Yeah, agreed. :slight_smile: