selecting units and moving them using click

hi guys, i am currently designing a new type of RTS style game and i ran into a problem. i need to get a select and move using mouse. script working like seen in normal real time strategy games such as starcraft or supreme commanders.

i used a code from a tutorial i found called generals(

i couldn't get the script to work for my project

thanks again

I'm not going to write your script for you... unit selection and moving is a relatively involved process in Unity, but I'll outline some of the basics for you:

  • Use raycasting to detect what the mouse is currently clicked on.
  • If it's a unit, select it. Deselect all the other units (unless CTRL or something is held down, for multiple unit selection (optionally)).
  • If it's anything else (ground, terrain, etc), tell the unit(s) to move to that location. You may want to look into the A* pathfinding system, someone has coded a Unity implementation of that.

I think if you download the shadows demo you will probably have a script that suits your needs my friend, it allows you to click on objects that are Rigidbody and move them.

check this...