How to: trail follow a moving colided object?

I am a beginner in JavaScript and gamemaking. I have two questions.

  1. How do I make a particle trail follow a collided object?
    This script instantiates a particle system when a target object is collided with a bullet
    but the trail does not follow the target. The particle system is a child of the target object,
    so it seems that it should follow the target, but it just keeps emitting for a few seconds in one spot.

  2. How do I make a game go into Pause by hitting the “P” keystroke?

Pause should go something like:

if (Input.GetKeyDown("P")) {
if (Time.timeScale == 0.0) Time.timeScale = 1.0;
else Time.timeScale = 0.0;
}

As for your other issue, any instantiated object is by default created with no parent. Put

instantiatedExplosion.tarnsform.parent = transform;

immediately after your instantiate statement. (This is assuming the script is running on the object you wish to be the parent)

Thanks, the trails works like a charm.

I am a little unclear where to apply the pause script.

Thanks again

Andy

The pause script goes into any behavior attached to an object, inside an Update() function. Since Input and Time are both classes which are accessed globally, it makes no difference what script those lines are stuck in, as long as it’s attached to an object (and only one object!).

So the final version would look like this:

function Update () {
if (Input.GetKeyDown("p")) { 
if (Time.timeScale == 0.0) Time.timeScale = 1.0; 
else Time.timeScale = 0.0; 
}
}

So use a small “p” and Also open the input manager, and assign “p” as a user key

Cool stuff Star manta-thanks :wink:
AC

There’s no need to assign buttons if using GetKey (although you’re correct about using a lowercase p - my bad). It’s also true that a more “proper” way would be to use Input.GetButtonDown(“Pause”) instead, and assign a pause key in the input manager. GetKey is just the quick n dirty method.