start a void from string unity code example
Example: start a void from string unity
using UnityEngine;
using System.Collections.Generic;
public class ExampleScript : MonoBehaviour
{
// Launches a projectile in 2 seconds
Rigidbody projectile;
string voidName = "LaunchProjectile";
void Start()
{
Invoke(voidName, 2.0f);
}
void LaunchProjectile()
{
Rigidbody instance = Instantiate(projectile);
instance.velocity = Random.insideUnitSphere * 5.0f;
}
}