Синтаксис:
Используется csharp
[SerializeField] private Vector3 moveDirection;
private Rigidbody[] _player;
private void Start()
{
_player = FindObjectsOfType<Rigidbody>();
}
private void FixedUpdate()
{
OnButtonLeft();
OnButtonRight();
}
public void OnButtonLeft()
{
_player.GetComponent<Rigidbody>().velocity += moveDirection;
}
public void OnButtonRight()
{
_player.GetComponent<Rigidbody>().velocity -= moveDirection;
}
private Rigidbody[] _player;
private void Start()
{
_player = FindObjectsOfType<Rigidbody>();
}
private void FixedUpdate()
{
OnButtonLeft();
OnButtonRight();
}
public void OnButtonLeft()
{
_player.GetComponent<Rigidbody>().velocity += moveDirection;
}
public void OnButtonRight()
{
_player.GetComponent<Rigidbody>().velocity -= moveDirection;
}
ошибка в функциях OnButtonLeft и OnButtonRight не знаю как правильно оформить строку _player.GetComponent<Rigidbody>().velocity = moveDirection;