Не понимаю как решить эту проблему в ошибке CS1061, для движения камеры на Юнити за игроком?
Вот код и ошибка полностью
Assets\Graphs\CameraMove.cs(26,16): error CS1061: 'Transform' does not contain a definition for 'GameObject' and no accessible extension method 'GameObject' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMove : MonoBehaviour
{
public float dumping = 1.5f;
public Vector2 offset = new Vector2(2f, 1f);
public bool isLeft;
private Transform player;
private int lastX;
void Start()
{
offset = new Vector2(Mathf.Abs(offset.x), offset.y);
FindPlayer(isLeft);
}
public void FindPlayer(bool playerIsLeft)
{
player.GameObject.FindGameObjectWithTag("Player").transform;
lastX = Mathf.RoundToInt(player.position.x);
if (playerIsLeft)
{
transform.position = new Vector3(player.position.x - offset.x, player.position.y + offset.y, transform.position.z);
}
else
{
transform.position = new Vector3(player.position.x + offset.x, player.position.y + offset.y, transform.position.z);
}
}
void Update()
{
if (player)
{
int currentX = Mathf.RoundToInt(player.position.x);
if (currentX > lastX) isLeft = false; else if (currentX < lastX) isLeft = true;
currentX = Mathf.RoundToInt(player.position.x);
Vector3 target;
if (isLeft)
{
target = new Vector3(player.position.x - offset.x, player.position.y + offset.y, transform.position.z);
}
else
{
target = new Vector3(player.position.x + offset.x, player.position.y + offset.y, transform.position.z);
}
Вы в блокноте пишете или в нормальной IDE?
Откуда вот это:
player.GameObject
?
Вам же написали - нет такого поля GameObject. Хотя бы автодополнение откройте и посмотрите какие есть поля и методы