Search Unity

Curve Editor Usage

Discussion in 'Scripting' started by Dezeris85, Jul 16, 2020.

  1. Dezeris85

    Dezeris85

    Joined:
    Dec 16, 2016
    Posts:
    24
    Hey all, I was wondering if someone could point in the right direction. I just need to be able to use a curve editor on a height map so that further away from the center point of the map the height gets lower. I have never used the curve editor so little lost. Thanks ahead of time.
     
    OmniGiovanni likes this.
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Put this on a script:
    Code (csharp):
    1. public AnimationCurve slopeCurve;
    Now check the inspector, you'll see a curve there you can edit.

    To evaluate a point, it'd look something like:
    Code (csharp):
    1. float distfromCenter = Vector3.Distance(point, centerPoint);
    2. float curveValue = slopeCurve.Evaluate(distFromCenter / maxDistance);
     
    Dezeris85 likes this.