Сам код:
Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
private LineRenderer lineRenderer;
// Start is called before the first frame update
void Start()
{
lineRenderer = GetComponent<LineRenderer>();
DrawSineWave();
}
void DrawSineWave(Vector3 startPoint, float amplitude, float wavelength)
{
float x = 0f;
float y;
float k = 2 * Mathf.PI / wavelength;
lineRenderer.positionCount = 200;
for (int i = 0; i < lineRenderer.positionCount; i++)
{
x += i * 0.001f;
y = amplitude * Mathf.Sin(k * x);
lineRenderer.SetPosition(i, new Vector3(x, y, 0) + startPoint);
}
}
// Update is called once per frame
void Update()
{
}
}
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
private LineRenderer lineRenderer;
// Start is called before the first frame update
void Start()
{
lineRenderer = GetComponent<LineRenderer>();
DrawSineWave();
}
void DrawSineWave(Vector3 startPoint, float amplitude, float wavelength)
{
float x = 0f;
float y;
float k = 2 * Mathf.PI / wavelength;
lineRenderer.positionCount = 200;
for (int i = 0; i < lineRenderer.positionCount; i++)
{
x += i * 0.001f;
y = amplitude * Mathf.Sin(k * x);
lineRenderer.SetPosition(i, new Vector3(x, y, 0) + startPoint);
}
}
// Update is called once per frame
void Update()
{
}
}
Итог который пытаюсь получить:
Подскажите , где допустил ошибку, благодарю.