Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Python for Unity - Position

Discussion in 'Formats & External Tools Previews' started by sersol, Apr 8, 2020.

  1. sersol

    sersol

    Joined:
    Apr 7, 2020
    Posts:
    6
    Hey,

    I have been trying to control Unity with Python following the introduction given recently.
    See the intro if needed: https://forum.unity.com/threads/introducing-python-for-unity-editor.812748/

    I have sustained a connection between Unity 19.3 and Python 2.7, and now been able to manipulate assets as targeted. I can create - for instance - cubes with following commands in Python (also see the attachment for the full script at the bottom);

    Code (CSharp):
    1. cube = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube);
    My problem is related to the positioning of assets with Vector3. Whilst I try to transform the position of the cube, the system gives an error. I can use static properties such as Vector3.one but cannot construct any vector upon Vector3(float x, float y, float z) structure. For instance, changing Vector3.one to Vector3(1, 2, 3) does not work. I'm also trying to use numpy to define arrays but haven't had any remedy so far.

    upload_2020-4-8_16-49-6.png

    Any help will be appreciated.
    Thanks.
     
  2. sersol

    sersol

    Joined:
    Apr 7, 2020
    Posts:
    6
    Solved! I was hurrying up...

    The problem came through decimals. Adding decimal now the cube is created in the position defined with Vector3.

    Code (CSharp):
    1. Vector = UnityEngine.Vector3(2.0, 1.0);