1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GML Particle facing changes mid-motion?

Discussion in 'Programming' started by Sixmen, Apr 25, 2017.

  1. Sixmen

    Sixmen Guest


    I've set up a particle system for bullet trails. Every time I click the mouse, a bullet is created which moves towards the mouse. Particles shaped like white lines are created at the bullet object per step, creating a nice trail effect. The problem is that I have set the particle orientation to match the bullet direction.
    If I shoot straight it looks fine.

    Like this: - - - - - - -

    The problem is when I move the mouse around and shoot at random directions the orientation of the particles change mid-motion.

    Like this: - - - - / / /

    I'm guessing the new particles created at the end of the bullets lifespan take their orientation from the new bullets instead of the original one. Any way to prevent this and make the orientation stay the same throughout the bullets lifespan?

    The create event for the bullet looks like this:
    //Create system
    ps = part_system_create();
    //Run script
    //Create emitter
    pe = part_emitter_create(ps);
    The step event for the bullet looks like this:
    I would appreciate any input on the matter.
    Thank you!
  2. Neptune

    Neptune Member

    Jun 21, 2016
    You could try skipping using an emitter, and use part_particles_create()... Although the more i think about it, im unsure how you could have different angles for each bullet.
  3. Joshua Allen

    Joshua Allen Member

    Jun 20, 2016
    Try changing your step event to:
    part_type_orientation(global.pt_ptrail, image_angle, image_angle, 0, 0, true);
    part_particles_create(ps, x, y, global.pt_ptrail, number);
  4. Sixmen

    Sixmen Guest

    Thank you Joshua! Works like a charm, although I'm not sure why.
  5. Joshua Allen

    Joshua Allen Member

    Jun 20, 2016
    It's because global.pt_ptrail is a pointer to the data the makes up the particle. Whenever you create a new particle, a copy of that data is added to a particle system. Each time a new bullet was being created it would change the global.pt_ptrail data so every new copy of global.pt_ptrail would use the new data. All my code is doing is changing the data before a particle is copied.

Share This Page