# How To Shoot A Raycast To A Location Where Particles Hit

Hello, everyone.

I’m planning on firing a ray from a person’s head, when another player gets a headshot on them. The raycast’s hit position would be wherever the particle effect’s Acceleration & Speed properties would determine where the particles go. I’m pretty bad at explaining things, so here’s two images hopefully better describing what I’m trying to achieve. It’s probably a simple physics equation, but I’m not sure. This would dynamically update with the part if it moves. I also plan on repurposing it for other splats in-game such as waterfalls and the like.

Current Behavior:

What I hope to achieve:

2 Likes

This issue sounds like you should be doing the reverse of what you have in mind. Like, raycast where splash pooling should be, get your particles to emit towards that point, then make the splash visible overtime.

Let the end position of your raycast dictate where particles should go instead of letting the particles dictate where a raycast is created.

1 Like

The question still is, how would I determine where the particles would go in that case?

I feel like it’d be better to have the particles make the splash instead of the opposite.

You can angle your part or attachment in such a way that allows the particle to aim a certain way and then do some mathy calculations (i.e. distance) to set Speed, Acceleration or any other property you need. If you dictate the endpoint first, then you can fill in the distance between the start and the end with particles.

I don’t assume it’s entirely impossible to calculate a raycast based off of particle properties alone if you use properties like Surface, but I can see that being significantly more difficult because you have to find where the bullet enters the character, flip that over to the other side then raycast outward somewhere. Plus, I can only assume various conditions may possibly need to be hardcoded depending on what you’re aiming as far as particles go (narrow or wide depending on where player was shot or what gun was used, if splash should occur or not, etc).

I personally think it’d be easier to dictate where particles should go rather than allow particles to determine the raycast because there’s less factors involved, but whatever floats.

You can use FindPartOnRay. There’s an example specifically for getting a players head from a raycast on the Developer Hub. Workspace | Documentation - Roblox Creator Hub

OP is trying to create a ray based on ParticleEmitter properties (Speed, Acceleration). This would be sufficient enough a reply to determine which ray function should be used, but it doesn’t help in determining the start or end points of the ray.

Speaking of, forgot to mention in my own replies that the Speed property of a ParticleEmitter wouldn’t help in calculations because it’s almost a useless variable. It’d be good for determining how quickly the decal pools or expands, but on the ray itself has no business.

1 Like

I’m guessing speed would be useless because of the acceleration property, yes?

Also, if any of you have ever played Halo 3, the particles appear to make blood decals when they hit the ground. This could be due to the particles being physically simulated, but I’m not entirely sure.

If I manage to come up with a system for this, I’ll definitely open source it alongside my decal engine.

Acceleration has X, Y and Z values so you could probably use some trickery, combine it with the surface of which the particle is emitting from and get a direction from those values. With the direction, you’ll have to translate your start point as essentially the opposite side of where your projectile is entering (front left temple → back right of head). Once you have start and direction, you can use a ray function to get the end point.

I don’t know how this works but I have a generally vague idea of what you may need to be looking for. Speed wouldn’t help determining start or end points primarily because it’s not direction-specific. The least it’d do is help you determine how fast things should happen (when surface-splashes should appear, or how quickly they should pool, or anything that has a gradation value).

1 Like