T
T
terguew562022-01-21 10:58:21
C++ / C#
terguew56, 2022-01-21 10:58:21

What to do with error CS1061 on Unity?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    [SerializeField] private float _speed;
    private Vector3 _input;

    private Rigidbody2D _rigidbody;

    private void Start()
    {
        _rigidbody = GetComponent<Rigidbody2D>();
    }
    
    private void FixedUpdate()
    {
    	move();
    }

    private void move()
    {
    	_input = new Vector2(Input.GetAxis("Horizontal"), 0);
        _rigidbody.addForce(_input * _speed);  
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2022-01-21
@vabka

1. Learn to ask questions. If you answer the question from the title, then the answer will be "Do whatever you want, you can leave it as it is and admire it"
2. Learn to read the rules and make posts in accordance with them.
Here where here for example language D? I can clearly see that there is C# with Unity. There is also no layout.
RigidBody does not have an addForce method.
List of all available methods here: https://docs.unity3d.com/ScriptReference/Rigidbody.html

L
LittleBob, 2022-01-21
@LittleBob

What line is the error on? More specifics and useful information, it is difficult to answer questions when they are so abstract.
Try writing AddForce instead of addForce.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question