Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Endless sprite shape world generator

Discussion in 'Scripting' started by zielakless, Mar 31, 2023.

  1. zielakless

    zielakless

    Joined:
    Jan 31, 2019
    Posts:
    3
    Hello. I need a little help. Am I able to create an endless map generator using Sprite Shapes? I would like the map to hide/destroy behind me and generate in front of me.

    Here's my current code:
    Code (CSharp):
    1.  
    2. for(int i = 0; i < levelLength; i++) {
    3.     lastPos = transform.position + new Vector3(i * xMultiplier, Mathf.PerlinNoise(0f, i * noiseStep) * yMultiplier);
    4.     spriteShapeController.spline.InsertPointAt(i, lastPos);
    5.  
    6.     if(i != 0 && i != levelLength - 1) {
    7.         spriteShapeController.spline.SetTangentMode(i, ShapeTangentMode.Continuous);
    8.         spriteShapeController.spline.SetLeftTangent(i, Vector3.left * xMultiplier * curveSmoothnes);
    9.         spriteShapeController.spline.SetRightTangent(i, Vector3.right * xMultiplier * curveSmoothnes);
    10.     }
    11. }
    12.