cript\player.cs(14,29): error CS1955: Non-invocable member 'Rigidbody2D' cannot be used like a metho

я написал скрипт точь в точь, но оно не работает. При rb = GetComponents (); не признает знаки <> и выдает ошибку ssets\script\player.cs(14,14): error CS0029: Cannot implicitly convert type ‘UnityEngine.Rigidbody2D[ ]’ to ‘UnityEngine.Rigidbody2D’ Есть варианты, как-то и что-то исправить???
All script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class player : MonoBehaviour
{
public float speed;

private Rigidbody2D rb;
private Vector2 moveInput;
private Vector2 moveVelocity;
void Start()
{
rb = GetComponents (); //problem area
}

void Update()
{
moveInput = new Vector2(Input.GetAxisRaw(“Horizontal”), Input.GetAxisRaw(“Vertical”));
moveVelocity = moveInput.normalized * speed;
}

void FixedUpdate()
{
rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);
}
}
Butif i delite >, go new problem: Assets\script\player.cs(14,29): error CS1955: Non-invocable member ‘Rigidbody2D’ cannot be used like a method.

Please use code-tags when posting code and not plain-text as it’s hard to read.

You’ve added a space inbetween “GetComponents” and “();”. This is wrong and is likely confusing the compiler. Remove the space.

It should also be rb = GetComponent<Rigidbody2D>(); not GetComponents

1 Like

Well spotted. My early morning eyes didn’t see that!