Search Unity

War Thunder aiming system

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

  1. Zenden1

    Zenden1

    Joined:
    May 20, 2017
    Posts:
    50
    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. Zenden1

    Zenden1

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

    AndersMalmgren

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

    Zenden1

    Joined:
    May 20, 2017
    Posts:
    50
    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:
    4,297
  6. Zenden1

    Zenden1

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

    AndersMalmgren

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