Search Unity

[SOLVED]What is the best way to get these vector positions

Discussion in 'Scripting' started by asdfasdf234, Jan 18, 2019.

  1. asdfasdf234

    asdfasdf234

    Joined:
    Nov 27, 2015
    Posts:
    76


    Is there another way to do this, that doesent require moving an object to get the positions?
    (green lines indicate distances, the orange circles indicate the positions that i need to add to a list)

    Code (CSharp):
    1.        
    2.  
    3.             List<Vector3> vecArray = new List<Vector3>();
    4.  
    5.             //START POSITION and ROTATION
    6.             pathPointBottomSetter.position = Vector3.zero;
    7.             pathPointBottomSetter.rotation = Quaternion.Euler(Vector3.forward * 15);
    8.  
    9.             pathPointBottomSetter.Translate(Vector3.down * 5, Space.Self);
    10.             vecArray.Add(pathPointBottomSetter.position);
    11.             pathPointBottomSetter.Translate(Vector3.right * 5, Space.Self);
    12.             vecArray.Add(pathPointBottomSetter.position);
    13.             pathPointBottomSetter.Translate(Vector3.left * 5, Space.Self);
    14.             pathPointBottomSetter.Translate(Vector3.left * 5, Space.Self);
    15.             vecArray.Add(pathPointBottomSetter.position);
    16.  
     
    Last edited: Jan 18, 2019
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
    Vector3 bottom = box.transform.forward * 5 ;
    Vector3 left = bottom - box.transform.left * 5 ;
    Vector right = bottom + box.transform.right * 5 x
    Untested
     
    asdfasdf234 likes this.
  3. asdfasdf234

    asdfasdf234

    Joined:
    Nov 27, 2015
    Posts:
    76
    Omg thank you, wtf was I doing.......
     
    Antypodish likes this.