Automatically storing mouse position in array
Hi guys,
Is that possible in unity to automatically storing mouse position while moving the mouse? if that's possible, can anyone provide me with documentation or example to do that?
Answer by Salocin19 · Mar 10, 2016 at 07:24 PM
Here's an example -- hope it helps!
public class RecordMouseInput : MonoBehaviour
{
private List<Vector3> recordedMousePositions = new List<Vector3>();
void Update()
{
if (Input.GetMouseButtonDown(0))
{
recordedMousePositions.Add(Input.mousePosition);
}
}
}
Thanks for your answers, and Sorry for my late response, i've been busy this couple weeks...
btw, how can i get the value from this List? can u give some documentation or example? i never use List before :D and another questions, can i do the same with touch input?
Answer by sahadha777 · Apr 07, 2020 at 07:07 AM
How should I change the script in order to store multiple mouse position values? I don't know technically it is correct or not - An array of list contains multiple Vector3 mouse position values. @Salocin19
Your answer
Follow this Question
Related Questions
Problem Destroying Component 0 Answers
Unable to load Json to an object array 1 Answer
reaching the limit of a Raycast[] array? 0 Answers
Similar function for each in array 1 Answer