Search Unity

Change Direction of Particles by Player Input?

Discussion in 'Navigation' started by MichaelHotte, Mar 2, 2015.

  1. MichaelHotte

    MichaelHotte

    Joined:
    Feb 22, 2015
    Posts:
    31
    In my game the player has a particle system attached to it as a child so it'll follow the player around the game. I'd like to change the direction the particles emit from player input. For instance, if I move up the particles are emitting downward. If I move left the particles will emit to the right. Is there a possible way to do this? Here is my code of how I want the code set up if all possible. If there is way to do this in C# and not Javascript I could work with that as well.

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

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    You could just rotate the emitter, or if you have a set number of directions e.g. 8, you could create separate emitters for each direction then switch them on and off.