Unity3D Tutorial - Custom Mouse Cursor For Grabbing Objects

preview_player
Показать описание
This video explains how to create a custom mouse pointer in a simple scene which only contains a draggable cube. To achieve the effect, we make use of the Cursor class from the unity API to exchange the displayed sprite. Furthermore we take a look at the OnMouseEnter(), OnMouseExit(), OnMouseDown() and OnMouseUp() functions to handle the users clicks on the cube.

Рекомендации по теме
Комментарии
Автор

Thanks the Gods for this tutorial - I've been looking into this for a while but seen many complicated video that include manual ray tracing...good job!

fisslewine
Автор

Thank you very much. (First my cursors wasn't in the appropriate format, in PSD I made some new as *png; in unity I changed them into cursors and now its well done)

AKSenor
Автор

Does cursor change functionality not work with these newer releases? I can't find anything related to on demand cursor changes, and the syntax has changed so that it is no longer possible to do this.

datscootusee
Автор

Add: I tried to use it with a 2D menu. But the buttons do not change the cursor on hover. Any idea how to fix it?

AKSenor
Автор

Hey Great tutorial!! quick question, how would I select and object using the raycast I'm operating using the xbox controller, instead of a mouse?

RaycastHit hit;
float theDistance;
//Debug Raycast in the Editor - SO WE CAN SEE IT! - MAKES LIFE EASIER!
//Vector3 forward = * 10;
Vector3 back = new * Time.deltaTime * 10, Input.GetAxis("XBOX.1.LT") * Time.deltaTime * 10, * Time.deltaTime * 10);
Debug.DrawRay(transform.position, back, Color.green);

if (Physics.Raycast(transform.position, (back), out hit))
{
if (hit.collider.gameObject.tag == "tile")
{
theDistance = hit.distance;
print(theDistance + " " +
if
{
Cube.Selected = this.gameObject;
}
}
}

I created a separate class called raycastFoward, and the item I want to select is a class called Cube. I end up selecting the drawn ray, Im trying to select a game of object from another class instead, is this the wrong way to pass the argument, plus my script is attached to a game object child of my main camera.

GEORGE.M.M
Автор

Thanks. I wish to implement this kind of feature into a 3d platformer to combine classic platformer with more controlled tricks similar to point and click games where the character is still but the player can click and grab objects he can't reach but still gets for no reason

magnusm
Автор

Sir Thank you very much, but can you please tell me how to increase the scale of the custom cursor which you used inside cursor. set cursor() in the sense with above video like the grabbing hand icon ..I need to increase the size of it by x and y axis....so that when the mouse hovers over it it should appear large than the default Please help... thank you

hemanthjagadeesh
Автор

I saw another video called Unity tutorial : Smooth Drag and drop in unity.
Where he only used a single script on the object to move it and he didn't need to get any components and used the world and mouse positions to navigate and move the object. How is this one different and is it better or worse for performance in big games?
Just asking

magnusm
Автор

Thumbs up ! Great tutorial, I actually try to use it on a first person test game I'm making, the issue I have is that I can move the object from any distance, which makes it unrealistic for my first person scenario, can it be modified to drag the object(s) from a certain distance from the object ? Keep up the good work :)

vasileioskontas
Автор

i want to do it in 2D and i have no idea of how

ikigailess