I need to do a list of positions of an object as time passes, so I'm having an error whenever I try to add it to a list variable. I'm trying to add it on a list and later use something like Debug to display the list on the console.
Here is the code snippet I'm using:
public List listOfPosition = new List();
void Update (){
if(Input.anyKey)
{
Debug.Log("A key or mouse click has been detected");
listOfPosition.Add(transform.position.x);
listOfPosition.Add(transform.position.y);
}
The error that I've been getting is :-
1) The best overloaded method match for 'System.Collections.Generic.List.Add(UnityEngine.Transform)' has some invalid arguments
2) Argument '#1' cannot convert 'float' expression to type 'UnityEngine.Transform'
I have gone through the code multiple times and have referred to a number of sources but I still can't manage to see a workaround.
↧