KraGenDeveloper
@KraGenDeveloper
Unity Developer

Error CS1061: 'Vector3' does not contain a definition for 'transform' and no accessible extension method 'transform как исправить?

Как можно исправить данный код что бы он работал?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerST : MonoBehaviour
{
    public GameObject camera;
    public float speed = 20f;
    public Joystick joystick;
    Rigidbody  rb;
    // Start is called before the first frame update
    void Start()
    {
        rb= GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    void FixedUpdate(){
        rb.AddForce(camera.transform.forward * joystick.Vertical * speed, 0f, camera.transform.right * joystick.Horizontal * speed);
    }
}


Скрипт вешается на сферу (игрок) и по идее игрок должен двигаться по вектору взгляда камеры.
НО Вылазит ошибка: Assets\Scripts\PlayerST.cs(23,86): error CS1061: 'Vector3' does not contain a definition for 'transform' and no accessible extension method 'transform' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?)
  • Вопрос задан
  • 181 просмотр
Решения вопроса 1
freeExec
@freeExec
Участник OpenStreetMap
Разберитесь с аргументами AddForce, у вас там каша.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы