- Home /
Vizualized echo (sound rays)
Hello, i need a script wich emits a defined amount of rays from a point in C#. I have got an example for you who may not understand the questions: https://m.youtube.com/watch?v=tuOC8oTrFbM (if its still unclear, i mean the rays, not the footsteps)
Answer by Kishotta · Jun 21, 2017 at 08:08 PM
This should get you started. Note all of the vectors generated are length 1, so you can easily multiply them by whatever "speed" you want your rays to spread.
You'll probably need to instantiate some objects with colliders and trail renderers to get the effect of the video.
public int RayCount;
List<Vector3> directions = new List<Vector3> ();
private void OnValidate () {
directions = new List<Vector3> ();
float step = (Mathf.PI * 2) / (float) RayCount;
for (int i = 0; i < RayCount; i++) {
directions.Add (new Vector3 (Mathf.Cos (i * step), Mathf.Sin (i * step), 0));
}
}
private void Update () {
foreach (Vector3 direction in directions) {
Debug.DrawRay (transform.position, direction, Color.red);
}
}
Your answer

Follow this Question
Related Questions
good looking god-rays that will work on iPhone? 3 Answers
What does AudioClip.GetData give me? 1 Answer
Movement shows black borders in objects 0 Answers
[C#] How to transform world space to local space? 1 Answer
Drawing a 3d Cone ray 2 Answers