PE lost

ey how do i make when i touch a object (with.tag: glitter)
there comes a particle effect attached to my character
(it must work like a power-up)
it is just creating a particle after touching and attached it to player
could someone help me ?

What you will need is to look up the OnTriggerEnter and the Instantiate code in the scripting reference.

When your character moves into the glitter power up, the OnTriggerEnter can instantiate a particle where your player is and make it glitter.

Read up on those and see if you can figure it out! We will try and help if you need additional help, but try and read up on those first.

something like this buty how do i make start a particle effect ?
could you help me ?

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag== “glitterpu”)
{
gotHit = true;
//Add speed and glitter here !! YEAH !
speed += 0.5;
Destroy (hit.collider.gameObject);
}
}

use Instantiate, look it up in the scripting reference.

Just instantiate the particle on your character.

how to add by my char the only i can find is:
// Instantiates prefab when any rigid body enters the trigger.
// It preserves the prefab’s original position and rotation.

var prefab : Transform;

function OnTriggerEnter () {
Instantiate (prefab);
}

could you help me ?

var glitterPrefab : Transform;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag== “glitterpu”)
{
gotHit = true;
//Add speed and glitter here !! YEAH !
speed += 0.5;
Instantiate (glitterPrefab , transform.position, transform.rotation);
Destroy (hit.collider.gameObject);
}
}

thats my own script from a other topic @_@
sick… -.-
but thanks for my own script
how do i attach it to my character ?
could someone help me ?

You need to go through a tutorial or two. Attaching scripts is very basic.

Start with the third person platformer and you’ll learn most of what you need to get started.

To attach a script to an object you drag the script from the Project view onto the object in the Hierarchy view or in the Inspector panel.

no when it creates
i mean in-game when it starter the scene then
i do instantiate and then i want to instiate to character not just in the scene
but when game is running
could someone help me with that ?

That’s what Futurebear’s posted code does.

You mean attach to character so it moves with them? If you do, you use childObject.transform.parent = parentObject.transform. Then childObject will move and rotate with parentObject.

where do i have to place that because everywhere i place i got errors
and not just 1 but 4 or 5 errors…
could someone help me ?

Your code doesn’t have the vars childObject or parentObject. You can*'t* just paste code and have it automagically work, it needs to be altered to fit your code.

childObject = instantiate whatever

parentObject is the object you want to attach the glitter to. Since that’s the object the script is running on, it is equal to this, so doesn’t need to be explicitly named. That is, once you have a reference to the child object, you can just use

childObject.transform.parent = this.transform

which shortens to

childObject.transform.parent = transform

If you need help with errors it’s always a good idea to post the errors. We can’t help “I have errors,” but we can help “I get a null reference exception on this line…”.

with this:
childObject(particleObject, hit.childObject.transform.parent.position, Quaternion.identity);
Destroy (hit.collider.gameObject);
}
it says error:
Assets/side-scroller/Scripts/Charwalker.js(43,4): BCE0005: Unknown identifier: ‘childObject’.
and
Assets/side-scroller/Scripts/Charwalker.js(43,36): BCE0019: ‘childObject’ is not a member of ‘UnityEngine.ControllerColliderHit’.

This line:

childObject(particleObject, hit.childObject.transform.parent.position, Quaternion.identity);

Is one that you changed from your original code.

How does this new form help you? What exactly is it intended to do?

childObject is not a function.
childObject is, in fact, defined nowhere in Unity’s code.
So it’s not a member of hit either.
You have to define it as a variable and set it equal to something.

I gave you 99% of the solution in my last post. All you have to change is “instantiate whatever” to actual code.

And add semicolons. And put the lines where they belong. :roll_eyes:

then i still got a error:
Assets/side-scroller/Scripts/Charwalker.js(44,5): BCE0077: It is not possible to invoke an expression of type ‘UnityEngine.Transform’.
when the script is :

var childObject : Transform;

childObject(particleObject, hit.transform.position, Quaternion.identity);

(sorry if it takes many time for you but i really want it in my game and really thanks vicenti)
could you help some more times ?

childObject = Instantiate( whatever );

var glitterPrefab : Transform;
var childObject : Transform;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag== "glitterpu")
{
gotHit = true;
//Add speed and glitter here !! YEAH !
speed += 0.5;
childObject = Instantiate (glitterPrefab , transform.position, transform.rotation);
Destroy (hit.collider.gameObject);
}
}

ok the script dont give errors but it is still not attaching to me…
so thanks for the script but can someone help me let it work ?

Sheesh, back to Vicenti’s earlier answer.

var glitterPrefab : Transform;
var childObject : Transform;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag== "glitterpu")
{
gotHit = true;
//Add speed and glitter here !! YEAH !
speed += 0.5;
childObject = Instantiate (glitterPrefab , transform.position, transform.rotation);
childObject.transform.parent = transform;
Destroy (hit.collider.gameObject);
}
}