Hi, i am very new to unity and i just tried to make a block dodge game posted to youtube (Brackeys https://www.youtube.com/watch?v=tyAutnOlsfA) evrything went good until i begun coding, i believed i filled out the exact same as he did, but i got an error saying: NullReferenceException: object not set to an intance of an object Player.fixedupdate () (atassets/player.cs:19) line 19 is the
rb.MovePosition(rb.position + Vector2.right * x);
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float speed = 15f;
private Rigidbody2D rb;
void start ()
{
rb = GetComponent();
}
void FixedUpdate ()
{
float x = Input.GetAxis("Horizontal") * Time.fixedDeltaTime * speed;
rb.MovePosition(rb.position + Vector2.right * x);
}
}
↧