Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Particle Emitter Problem?

Discussion in 'Physics' started by MichaelHotte, Mar 1, 2015.

  1. MichaelHotte

    MichaelHotte

    Joined:
    Feb 22, 2015
    Posts:
    31
    So I've attached a particle system to the player in my game. When the player moves I would like the particles to emit in the opposite direction that the player is moving. For example, if the player was going up, the particles would be emitting to the south. This would give it an appearance of the player being propelled by the particles. Any idea on how this would be done? I know how to add a particle system and play around with it. Though I am not sure as to how I would create this in C# or Javascript. Thanks in advance.
     
  2. Grillstern

    Grillstern

    Joined:
    Oct 14, 2013
    Posts:
    32
    If you add the particle System as a Child to your player and align it "to shoot backwards". the PS should always rotate with the player in the "right direction". Shouldn't be any problem. Depends on your game, player setup, style, 2D or 3D, sidescroller,...? Maybe more information required.
     
  3. MichaelHotte

    MichaelHotte

    Joined:
    Feb 22, 2015
    Posts:
    31
    Problem is my game is 2d and my character doesn't rotate. Here is how I want my code to be set up of it is possible to do it like this.

    Code (JavaScript):
    1.  
    2. function Update () {
    3. if(Input.GetKey(KeyCode.UpArrow)){
    4. //change direction of particles
    5. }
    6. if(Input.GetKey(KeyCode.DownArrow)){
    7. //change direction of particles
    8. }
    9. if(Input.GetKey(KeyCode.LeftArrow)){
    10. //change direction of particles
    11. }
    12.  
    13. if(Input.GetKey(KeyCode.RightArrow)){
    14. //change direction of particles
    15. }
    16.  
    17. }
    18.