Hi, I’m following Sykoo’s RPG tutorial and got this error
Assets\Scripts\playerMovement.cs(33,23): error CS0029: Cannot implicitly convert type ‘UnityEngine.Transform’ to ‘UnityEngine.GameObject’
Here is the code
public class playerMovement : MonoBehaviour
{
//variables
public float movementSpeed;
public GameObject playerMovePoint;
private GameObject pmr;
//functions
private void FixedUpdate()
{
//Player Controls
Plane playerPlane = new Plane(Vector3.up, transform.position);//Creating a plane and detecting mouse click on it with ray
Ray ray = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);// stores mouse position into ray
float hitDistance = 0.0f;
if(playerPlane.Raycast(ray,out hitDistance))
{
Vector3 mousePosition = ray.GetPoint(hitDistance);
//Quaternion targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
if (Input.GetMouseButtonDown(1))
{
pmr = Instantiate(playerMovePoint.transform, mousePosition, Quaternion.identity);
}
}
}
}
This is where I get the error pmr = Instantiate(playerMovePoint.transform, transform.position, Quaternion.identity);