Moba/Dota/Hon/LOL auto attack system and click to attack? how

So ive been working non stop to try and come up with a code that will allow me to move in range and start auto attacking creeps. After that i want the option to right click and select a specific topic? does anyone have a link to a video that shows how to do this? or specifically have a code your willing to share. Preference is JavaScript. Keep in mind i also need to keep my move script working. Right click to move and select targets. PLEASE HELP ME!

When you select a target that you want to attack.

  1. set in a parameter the range of your attack

  2. Check if the unit is in range FIRE, but if the unit is not in range move towards him.

  3. And your method for fire should not fire at the target every frame it should fire every second if he is having attack speed of 1. So to do that you have to keep the time that the last projectile is fired and after one second fire again.

    public void FireAtTarget(Target enemy)
    {
    if (distanceToEnemy < fireDistance)
    {
    if (Time.deltaTime - 1f > lastFireTime)
    {
    lastFireTime = Time.deltaTime;
    //make a projectile fly towards him
    }
    }
    }

Wellcome to Unity and dont forget to rate the answers :slight_smile: