Search Unity

War Thunder aiming system

Discussion in 'Scripting' started by zenden_1, Sep 16, 2018.

  1. zenden_1

    zenden_1

    Joined:
    May 20, 2017
    Posts:
    53
    Hello, i want to make a aiming system like war thunder.

    I search to make system who cursor is overlaping

    Like this vidéo :


    I already make a script for rotation but i don't now how make cursor system.

    Code (CSharp):
    1. ector3 direction = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z) - transform.position);
    2.  
    3.             Quaternion rotation = Quaternion.LookRotation(direction);
    4.  
    5.  
    6.             transform.rotation = Quaternion.Lerp(transform.rotation, rotation, shipTurnSpeed * Time.deltaTime);
     
  2. zenden_1

    zenden_1

    Joined:
    May 20, 2017
    Posts:
    53
  3. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    The outer ring is were you wanna go and the inner one syncs to the actual plane. Nothing fancy going on
     
  4. zenden_1

    zenden_1

    Joined:
    May 20, 2017
    Posts:
    53
    For me, is more easy to say as to do. How i can do that, i don't understand
     
  5. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
  6. zenden_1

    zenden_1

    Joined:
    May 20, 2017
    Posts:
    53
    I have to set the two cursor in UI ? Or in a gameobject forward the plane ?
     
  7. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You use world cordinates and translate them into screenspace and place the UI elements correctly