Confirmedusers, editor, Administrators
886
edits
CreativeMD (talk | contribs) (Created page with "VintageStory offers a variety of different types of particles. This tutorial will explain you how to create particles in code and show you some of the possibilities. If you wa...") |
CreativeMD (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
= SimpleParticleProperties = | = SimpleParticleProperties = | ||
== Spawn particles == | |||
So let's spawn some really basic particles. I suggest to create a static field for your particle properties: | |||
<syntaxhighlight lang="c#"> | |||
public static SimpleParticleProperties myParticles = new SimpleParticleProperties(1, 1, ColorUtil.ColorFromArgb(50, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(), new Vec3f()); | |||
</syntaxhighlight> | |||
Now we have the property, the only thing what is left to do is to set the position and spawn them into the world. I'm gonna use the <code>OnInteracting</code> method inside the Item class (you can read more about this in the Collectibles Tutorial): | |||
<syntaxhighlight lang="c#"> | |||
public override bool OnInteracting(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) | |||
{ | |||
myParticles.minPos = byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight(), 0).Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw); | |||
byEntity.World.SpawnParticles(myParticles); | |||
} | |||
</syntaxhighlight> | |||
This will spawn some white cube particles, which simply fall to the ground. They are spawned right in front of the player. | |||
[[File:BasicParticles.png]] | |||
== Properties Overview == | |||
There are several things you can configure. Here is an overview which covers all of the basics properties: | |||
=== Position === | |||
Basically there are two properties. One of the is the <code>minPos</code> property, which will determine the exact position where it will spawn. All particles will spawn there if <code>addPos</code> is not defined. | |||
=== Velocity === | |||
=== Life length === | |||
=== Quantity === | |||
=== Color === | |||
=== Glow === | |||
=== Opacity === | |||
=== Model === | |||
=== Gravity === | |||
=== Die In Air/ Liquid === | |||
= Other Particles = | = Other Particles = |