Hello everyone,
I’ve been working on a 2D rpg top down.
i’m trying to figure out how can i create a function where whenever i click on a spell icon i load it in the cursor (the cursor changes the sprite when you load the spell on it) then you have to click to fire it (if you click on the hitbox its a hit[animation/damage], else you miss) and then it goes empty (normal cursor sprite) and you have to load again.
I’m pretty new to this, i’m looking for guidance rather than you write it for me.
Thanks,
Sorry for the late answer:
The spell icon could be a button on your UI, you can put the code to change the cursor icon in there. To detect the click you can use Input.MouseButtonDown(0) 0 for left, 1 for right, 2 for middle (scroll click). This returns for the mouse state in the current frame so you can figure that out. As for the actual spell, I work in 3D so there may be a better solution than this for 2D but I would use Camera.ScreenPointToRay to find the point which was clicked on then work from there.
Good luck!