I'm trying to make the mouse cursor automatically move from a random place to a specific place on my unity game screen.
I'm using Mouse.current.WarpCursorPosition, and Vector3.MoveTowards for what i want to make.
But it doesn't work at all.
Here's my code.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
public class TestMousemove : MonoBehaviour
{
public GameObject G;
public float Speed;
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
Mouse.current.WarpCursorPosition(transform.position =
Vector3.MoveTowards(transform.position, G.transform.position, Speed * Time.deltaTime));
}
}
}
and this is how it works.
I want to make it move smoothly like the cursor follows the location.
Is there anyone knows about the question, please answer here.
Thank you