Answers for "how to make object follow cursor unity"

C#
3

unity set cursor position

//C#
    // Import
    using System.Runtime.InteropServices;
    
    // Inside class
    [DllImport("user32.dll")]
    static extern bool SetCursorPos(int X, int Y);
    
    // Example
    int xPos = 30, yPos = 1000;   
    SetCursorPos(xPos,yPos);//Call this when you want to set the mouse position
Posted by: Guest on January-06-2022
0

unity magnetize a 3d object to cursor

mousePosition = Input.mousePosition;
mousePosition.z = Mathf.Abs(cam.position.z - ball.position.z);
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
dir = mousePosition - object.position;
ball.AddForce ((dir).normalized * force);
Posted by: Guest on September-18-2021

Code answers related to "how to make object follow cursor unity"

C# Answers by Framework

Browse Popular Code Answers by Language