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.

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.