Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

New

Hi! I am New to Unity and the I have a problem with my script

Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

public float speed;
public float jumpForce;
public float moveInput;

private Rigidbody2D rb;

void start(){
rb = GetComponent<Rigidbody2D>();
}

void FixedUpdate(){

moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
}

}


And here is the error message:

NullReferenceException: Object reference not set to an instance of an object
PlayerController.FixedUpdate () (at Assets/PlayerController.cs:20