Inside Sphere#
Random / Inside Sphere
Can Read
Cannot Write
Description#
A random point placed anywhere inside a sphere of the specified radius
Parameters#
| Name | Description |
|---|---|
| Radius | How far from the center the point can be placed |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
using Random = UnityEngine.Random;
namespace VisualScript.Runtime
{
[Get]
[Title("Inside Sphere")]
[Category("Random/Inside Sphere")]
[Description("A random point placed anywhere inside a sphere of the specified radius")]
[Image(typeof(IconDice), ColorTheme.Type.Yellow, typeof(BadgeSphere))]
[Parameter("Radius", "How far from the center the point can be placed")]
[Keywords("Dice", "Vector", "Point", "Position", "Scatter", "Spread", "Volume")]
[Serializable]
public class TypeVector3RandomInsideSphere : TypeVector3
{
[SerializeField] private GetNumber m_Radius = new GetNumber(1f);
public override Vector3 Get(Args args)
{
return Random.insideUnitSphere * this.m_Radius.GetFloat(args);
}
public override string ToString()
{
return $"Inside Sphere ({this.m_Radius})";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnUpdate;
}
}