Hello guys, could help me to make a script that when clicking with the right mouse button, if there is an enemy walk and attack or if there is no enemy simply walk there
style LOL, Dota2, warcraft3.
thanks, sorry for my bad english.
detail: only C#
no, come back when you’ve actually tried something.
i try, but i can’t because don’t know how identify if exist one gameobject(tag “enemy”) where is mouse be, i no know how transfer this information for script Walk.c# of gameobject(tag "player).
see, i can use “Camera.main.ScreenToWorldPoint (Input.mousePosition);” to get position mouse, and use vector2.lerp(transform.position, (code up), 2*time.deltatime); for walker player, but if there is a gameobject(tag “enemy”); this code must moviment this gameobject(player) to position gameobject(enemy) the gameobject enemy when mouse catch. understand?
@Laperen
My apologies for not being clear, i don’t speak english, then… i have difficulty
The problem was not your english, but because you provided no information other than needing help. It looked like you were expecting a whole script custom made for you with no effort on your part.
I’d like to know if this is a 2D or 3D game, and the viewpoint(top down, or isometric like DOTA, etc), although I suspect it’s 2D considering what you have said in your second post.
I’d also like to know if you are using 2D or 3D collision.
Part of the problem is that I don’t know how you are using the ScreenToWorldPoint (Input.mousePosition).
In 3D you will need a raycast, and use the RayCastHit information, to get the world coordinates or enemy coordinates depending on what the ray has hit.
In 2D topdown you can use a circle cast and check if an enemy is overlapping the circle cast. if there is then target it, if not move to the mouse coordinates