I wrote a simple behaviour script for the player object but when I started using RigidBody2D in the code Unity doesn't understand it...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerBehaviour : MonoBehaviour
{
RigidBody2D rb;
int speedX;
void Start()
{
rb = GetComponent<RigidBody2D>();
speedX = -1f;
rb.velocity = new Vector2(1f, 0f);
}
}
Here's the error (in Unity because VSCODE and Rider don't show it): Error in Unity
I tried to make the code simpler and simpler and add the script to the Player sprite one more time, I expected that at some point the problem will disappear but it didn't...
it's Rigidbody2D not RigidBody2D the b is lowercase
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.