Jump to content

Making bullets by using particles


Poltergeist Azarov
 Share

You are about to reply to a thread that has been inactive for 3404 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Been trying to make some particle bullets and found some examples. The one I currently have seems to be too slow for a bullet. And the other problem is particles arent getting together with the center of screen when target is near. Center of the screen(target pointer/crossfire) and particles are only merging at around 200 meters away from particle source. Heres the sample script:


EmitBullet() {
float speed=100.0;
vector vel =llRot2Fwd(llGetCameraRot()) * speed;
llParticleSystem([
PSYS_PART_FLAGS, 259,
PSYS_SRC_PATTERN, 1,
PSYS_PART_START_ALPHA, 1.000000,
PSYS_PART_END_ALPHA, 0.000000,
PSYS_PART_START_COLOR, <1.000000, 1.000000, 1.000000>,
PSYS_PART_END_COLOR, <1.000000, 1.000000, 1.000000>,
PSYS_PART_START_SCALE, <1.000000, 1.000000, 0.00000>,
PSYS_PART_END_SCALE, <0.100000, 0.100000, 0.100000>,
PSYS_PART_MAX_AGE, 2.80000,
PSYS_SRC_MAX_AGE, 0.10000,
PSYS_SRC_ACCEL, vel,
PSYS_SRC_ANGLE_BEGIN, 0.000000,
PSYS_SRC_ANGLE_END, 0.000000,
PSYS_SRC_BURST_PART_COUNT, 1,
PSYS_SRC_BURST_RATE, 0.050000,
PSYS_SRC_BURST_RADIUS, 0.000000,
PSYS_SRC_BURST_SPEED_MIN, 100.000000,
PSYS_SRC_BURST_SPEED_MAX, 100.500000,
PSYS_SRC_OMEGA, <0.000000, 0.000000, 0.000000>,
PSYS_SRC_TARGET_KEY,(key)"",
PSYS_SRC_TEXTURE, ""]);
}
default
{
state_entry() { llRequestPermissions(llGetOwner(),PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA); }
run_time_permissions(integer perms)
{
if (perms & PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA)
{
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
}
}
attach(key attached)
{
if (attached == NULL_KEY) // object has been detached
{
}
else
{
llRequestPermissions(llGetOwner(),PERMISSION_TAKE_CONTROLS|PERMISSION_TRACK_CAMERA);
}
}
control(key id, integer level, integer edge)
{
if (level & CONTROL_ML_LBUTTON && llGetAgentInfo(llGetOwner()) & AGENT_MOUSELOOK)
{
EmitBullet();
}
}
}

 

Link to comment
Share on other sites

Interesting idea. Looking at the script, my first question is what the PSYS_PART_END_COLOR  and PSYS_PART_END_ALPHA values are doing thee. They're not supposed to have any effect at all without the PSYS_PART_INTERP_COLOR_MASK flag. Same with PSYS_PART_END_SCALE which requires the PSYS_PART_INTERP_SCALE_MASK to have any effect.

I can think of two possible reasons why the particles only appear 200 m away from the emitter, server lag and client lag. Although there doesn't seem to be a limit to how high you can set a particle's speed, I don't think the system was really made to cope with ones moving as fast as this and it's likely there is a slight delay from the "official" start of the particle's movement until the gpu actually gets around to render it.

Server lag can be reduced by setting the two variables speed and vel before the EmitBullet routine is triggered and possibly by removing those redunant parts of the llParticleSystem function. Don't expect much - or even noticeable - improvements though.

Client lag depends on how powerful and busy the client's gpu is and that can vary a lot.

The tracking issue may have something to do with the fact that particles are generated client side rather than server side but I'm way out of my depth already here so maybe I better leave it to somebody else to figure it out. :matte-motes-wink:

Link to comment
Share on other sites

That looks amzingly realistic!

Focusing on the muzzle flare rather than the bullet may have been the right thing to do regardless of the technical issues. How often do often actualy seen bullets in the air in real life? I never have and I've been dangerously close to them.

Link to comment
Share on other sites

The muzzle effect of it is something separated which is also more realistic than usual. The bullet trail effect is what I was trying to make. Its not that short as shown on preview. It gets long up to the target hit. Just seems short from the agent camera of mouselook as it should be :) I dont know much about real guns btw... 

Link to comment
Share on other sites

I made some bullets for a plasma turret that draws long trails using the ribbon particle. Maybe you have seen something like that?

However, this particles can't be created on its own - they are drawn by a moving prim.

A normal particle is always a square. You can put a texture on it so it can look like having a different shape. If you want a beam you need to fire many 100 fast particles in a stream.

Link to comment
Share on other sites

As you have said Nova, In fact, its not really possible to make a beam or trail by using ribbon on a static prim but after some work, I did it. It is kind of a tricky beam I can say. Had to spend a serious time on it to find a tricky way. Since my point is to make a gun which does not need to rez a prim. heres the another example preview. (This might be seem to be slow on this preview GIF. Its fast as it should be inworld). From the otherside, as shown on this example, I also simulated a bullet deviation which might be used in the near future.

Link to comment
Share on other sites


Poltergeist Azarov wrote:

I dont know much about real guns btw... 

In RL the only thing you may see is the muzzle flare. If you stand in the wrong (but not disastrous) place you hear the whistle as the bullet pass yo but you never actually see it. This is probably a bug but I haven't found out where to post bug reports about Real Life yet. Does anybody have the URL?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3404 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...