I was just messing around with particle effects and tried to make an explosion effect by instantiating a particle system.
I instantiated the particle effect using this block of code. I don’t fully understand how it works other than that it’s casting the particle effect into rigidbody. I found this from Unity - Scripting API: Object.Instantiate
Rigidbody clone;
clone = Instantiate(Explosion, transform.position, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
When I hit play the particle effect was successfully instantiated but then, I notice that there’s an error message in the console which is bugging me. The error message was
InvalidCastException: Specified cast is not valid.
(wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)