| 123456789101112131415161718192021 |
- using UnityEngine;
- public static class MathHelpers
- {
- public static float PerlinNoise2D(float x, float y, float scale)
- {
- return Mathf.PerlinNoise(x / scale, y / scale);
- }
- public static float CalculateSlope(Vector3 pointA, Vector3 pointB)
- {
- return Mathf.Abs(pointB.y - pointA.y) / Vector3.Distance(pointA, pointB);
- }
- public static Vector3 GetRandomPointInRange(Vector3 center, float range)
- {
- float x = Random.Range(center.x - range, center.x + range);
- float z = Random.Range(center.z - range, center.z + range);
- return new Vector3(x, center.y, z);
- }
- }
|