Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

New rect() between two Vector2

Discussion in 'Editor & General Support' started by valter-home, Dec 23, 2019.

  1. valter-home

    valter-home

    Joined:
    Sep 22, 2015
    Posts:
    73
    Sorry, maybe it's a trivial question but I can't solve it.
    I have two vectors, say Vector2 (10.10) and Vector2 (50.50). I would like to build a rect from one to the other of a certain height where the center of the rectangle is positioned in the middle of a virtual line that joins the two vectors.
    I have looked at all the properties of the rect () but it doesn't seem to be possible. Am I wrong?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,991
  3. valter-home

    valter-home

    Joined:
    Sep 22, 2015
    Posts:
    73
    Hi mgear, thanks for your reply.
    There is one thing that is not clear to me, I understand var size (the width and height of the rect.) but centerPoint in your example is the center between the two vectors but it should be "The position of the minimum corner of the rect". In fact the rect is not in the correct position, maybe I misunderstood?
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,991
    oh i see, you are correct.. i misread it as middle position :D

    you could then take smallest x and smallest y from those 2 vectors, to use as minimum corner.