Reputation: 41
I'm trying to get a camera to move whenever you press either WASD or the arrow keys, but it's throwing
Error CS0428 Cannot convert method group 'GetComponent' to non-delegate type 'Transform'. Did you intend to invoke the method?
On this script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameramover : MonoBehaviour
{
public Camera controlled;
Vector3 movement;
void Start()
{
Transform transform1 = controlled.GetComponent<Transform>;
}
void Update()
{
movement = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0.0f);
}
}
I tried invoking the method, but that threw CS0201, so I tried doing
new Transform(controlled.GetComponent<Transform>;)
and that didn't work either, so I went here to ask for help.
Upvotes: 3
Views: 66
Reputation: 41
Figured it out with the help of the wonderful people at the Game Dev Network discord server! i just had to add a pair of parentheses on the end of the controlled.GetComponen;
Upvotes: 1