Possible Particle function?

I am playing around with different particle system methods and I was wondering if someone could help me out. I do not know how to turn of the sphere collider in script, as well as this error which appears: (25,1): BCE0077: It is not possible to invoke an expression of type ‘UnityEngine.Transform’. In general I’m just curious if anyone could tell me if this type of system would work :slight_smile:

Thanks!

//Variables (START)_________
//The particles that will Instantiate on hit

var Particle1 : Transform;

//Speed of the Bullet
var bulletSpeed = 10;

var expireTime = 10;

//Variables (END)___________


function Start () 
{
//A soon as the projectile is created, make sure
//destroys itself
Destroy (gameObject, expireTime);
}

function Update () 
{
//Sends the projectile forward
transform(Vector3.forward * bulletSpeed * Time.deltaTime);
}

function OnCollisionEnter (hit : Collision)
{
if(hit.transform.tag == "floorMud")
	{
	Instantiate(Particle1, transform.position, transform.rotation);
	transform.renderer.enabled = false;
	transform.spherecollider.enabled = false;
	}
}

Hello,

Your error is due to you trying to call a variable as a function.
In your Update function you call transform(), but transform references the Transform component of the GameObject your script is attached to. You can’t call a Transform as a function, it just doesn’t work that way. What you can do is access it’s position and so something like this:

transform.position += Vector3.forward * bulletSpeed * Time.deltaTime;

This will then change the position of the Transform component of the GameObject to whatever :slight_smile:

Hope this helps,
Benproductions1

For the sphere collider you can add : gameObject.GetComponent(SphereCollider).enabled = false;

or if you want to destroy the object just use destroy(gameObject);