using UnityEngine;
public class PlayerControl : MonoBehaviour
{
private Rigidbody2D rb;
private float horizontalMove = 0f;
public float speed = 1f;
private Vector3 position = Vector3.zero;
void Start()
{
rb = GetComponent();
}
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * speed;
}
private void FixedUpdate()
{
Vector2 targetVelocity = new Vector2(horizontalMove * 10f, rb.velocity.y);
rb.velocity = targetVelocity;
}
}
да даУченик (64)
3 месяца назад
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <67e7964210a44789b2218ce9c1361100>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List`1[T] inEdges, System.Collections.Generic.List`1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <67e7964210a44789b2218ce9c1361100>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <67e7964210a44789b2218ce9c1361100>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <67e7964210a44789b2218ce9c1361100>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <67e7964210a44789b2218ce9c1361100>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <67e7964210a44789b2218ce9c1361100>:0)
Assets\Scripts\PlayerControl.cs(8,28): error CS1519: Invalid token '=' in class, record, struct, or interface member declaration
не могу понять почему, помогите разобраться.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerControl : MonoBehaviour
{
private Rigidbody2D rb;
private horizontalMove = 0f;
private float speed = 1f;
public PlayerControl(float speed)
{
this.speed = speed;
}
private Vector3 position = Vector3.zero ;
void Start()
{
rb = GetComponent; Rigidbody2D;
}
void Update()
{
HorizontalMove = Input.GetAxisRaw("Horisontal") * speed;
}
private void FixedUpdate()
{
Vector2 targetVelocity = new Vector2(HorizontalMove * 10f, rb.velocity.y);
rb.velocity = targetVelocity;
}
}