Hello getting a CS1061 error for the following code.
"Object does not contain a definition for “parent” …
"Object does not contain a definition for “position” …
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public bool hasBall = false;
public bool canSteal = false;
public GameObject ball;
[SerializeField] Transform ballTarget;
public GameObject currentArea;
private void OnCollisionEnter(Collision collision)
{
if (collision.collider.CompareTag("Player"))
{
Player player = collision.collider.GetComponent<Player>();
if (canSteal && player.hasBall)
{
//Turn canSteal off in case of multiple micro collisions
canSteal = false;
//Reparent the ball to the new player
player.ball.transform.parent = null;
player.hasBall = false;
hasBall = true;
ball = player.ball;
ball.transform.parent = this.transform;
ball.transform.position = ballTarget.position;
//Disable the area
currentArea.SetActive(false);
}
}
}
}
Anyone able to tell me what I’m missing here?