physics_particle_set_flags

使用此函数,可以更改单个粒子的粒子标志。index 值是 physics_particle_create() 函数返回的粒子 ID,而标志是以下常量的组合的返回值:

常量描述
phy_particle_flag_waterThe default properties for a soft body particle.
phy_particle_flag_zombieA zombie particle is one that will be destroyed in a single step with all others flagged in this way.
phy_particle_flag_wallThis defines the particle as static, essentially creating it as an immovable object in the physics simulation, as they will remain in a fixed position no matter what collides with them. You should use this flag rather than set the density to 0.
phy_particle_flag_springSpring particles produce the effect of being attached to one another, as if by a spring. Particles created with this flag are "connected" in pairs, with each particle being connected to the one that was closest to it at the time of creation. Once paired, particles do not change "partners" , and the farther an external force pulls them from one another, the greater the power with which they will collide when that external force is removed. Note that no matter how far paired particles get from each another, the connection between them will not snap.
phy_particle_flag_elasticElastic particles deform and may also bounce when they collide with other rigid bodies in the physics simulation.
phy_particle_flag_viscousA viscous particle is one that exhibits "clinginess" or "stickiness", like oil. Viscous particles will clump and stick together more.
phy_particle_flag_powderPowder particles produce a scattering effect such as you might see with sand or dust.
phy_particle_flag_tensileTensile particles are used to produce the effect of surface tension, or the taut curvature on the surface of a body of liquid. They might be used, for example, to create the surface tension you would see on a drop of water. Once the tension is broken, the particles bounce as if they were elastic, but also continue to attract each other. As a result, particles tend to form clusters as they bounce.
phy_particle_flag_colourmixingColour-mixing particles take on some of the colour of other particles with which they collide. Note that if only one of the two colliding particles is a colour-mixing one, the other particle retains its pre-collision colour.

这些标志使用位掩蔽创建最终输出值,然后选中该值以设置粒子类别的不同基本属性 (基本属性始终为 phy_particle_flag_water 的基本属性)。例如,如果要模拟具有表面张力的粘性液体,则可以使用 "|" 来掩蔽相应的位,如下例所示。通过这种方式,可以为创建的每个粒子类别设置不同的属性 (全局属性除外)。

 

语法:

physics_particle_set_flags(index, flags)

参数类型描述
indexPhysics Particle ID粒子的索引。
flagsPhysics Particle Flag Constant(s)要在粒子上设置的标志。

 

返回:

Real

 

例子:

var flags = phy_particle_flag_water | phy_particle_flag_viscous | phy_particle_flag_tensile;
physics_particle_set_flags(p, flags);

上述代码将创建一个变量来存储标志值,然后使用它来设置先前创建的粒子上的标志,并将索引存储在变量 "p" 中。