F
F
FiolDoll2020-11-06 12:51:33
Unity
FiolDoll, 2020-11-06 12:51:33

It is not possible to register the script "PlayerController", writes an error. What needs to be changed?

for the character, a script was written in the game under the style of TOP DOWN 2D. The script itself is done, BUT, the following problem pops up -
The type or namespace name 'rigidbody2D' could not be found (are you missing a using directive or an assembly reference?)

I have no idea how to solve it. Please help
the code itself:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehavior
{
public float speed;

private rigidbody2D rb;
private Vector2 moveVelocity;

void start()
{
rb = GetComponent();
}

private void Update()
{
Vector2 moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("vertical"));
moveVelocity = moveImput * speed;
}

void FixedUpdate()
{
rb.movePosition(rb.position + moveVelocity * Time.fixedDeltaTime);
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Makov, 2020-11-06
@FiolDoll

private rigidbody2D rb; - spelled incorrectly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question