Currently making a flamethrower and I need help detecting players that get hit by the flame which are particles.
Particle emitters cannot register what they “touch”. There is no such property, event, or function that enables this.
you may just have to place a block where the emitter is rendering particles, and listen to the
What I did with my dragon’s breath, was to cast rays ever so often, during the animation with the fire particle emitter running. Everywhere the cast ray would touch if it was not past a certain distance from the dragons mouth, I would attach a fire object to it, and if it had a humanoid, I would give it some damage.
On mobile, sorry
One way I believe that could help in finding if the user is in the general AoE would be to store the flamethrowers CFrame and use ObjectSpace on the flamethrower. (assuming the front of the flamethrower is the positive X axis in Objectspace)
From there you will run through the list of players to see if their humanoid root part is within a certain range on the Z and Y axis. You can set the amount of studs maximum from those two axis which will effectively create a cone in which would be considered that hit box. after creating your Cone you will need to find the distance between the flamethrower and the humanoid root part. (compare flamethrower position and humanoidrootpart position with magnitude). If both of those check out then the player should be damaged.
(Never used ObjectSpace on CFrames so correct me if I’m wrong please )
EDIT: Looks like I was wrong about object space? I did find a link that might aid you:
I know this is a long stretch, but have you considered using Raycasting to detect if a player hits a particle, that is to say (if it’s even possible) if the particle isn’t magically curving constantly in a different direction, just an idea.
Edit just as SelDarken said
If you need a thread on this you can find it in the wiki:
I assume this is because they are rendered locally as an object (as far as I know) and each of the particles is a local particle, not a server particle replicated to the client.
More than likely, they just aren’t added to the physics calculations, simply because that would be overwhelming on the system. Locality probably wouldn’t play a factor, since you can have purely local parts that can collide with the player and with each other. The only barrier is if you have FE, local parts will not collide with server parts.
Honestly, all the ideas on this thread are extremely overkill. @ClockworkSquirrel is using the best method, especially for a flamethrower.
You could raycasting from the particles and then detect if player is touching it
Do you mean raycasting from the emitter?
This would of course be one single raycast and there would be no way to check if the player was hit by an individual particle (something that is impossible without making your own particle system)
It’s similar to weapons, it detects wether it hits a humanoid. We could use this for particles.
? I’m not sure I understand what you’re saying.
I completely understand raycasting as I use it all the time, and I also understand the replication of particles in Roblox. I don’t really know what you mean by
In Raycasting, you can replace the second argument so that it racyasts forward in a certain direction. Using FindPartOnRay, we can then find the humanoid/player. This is how most weapons are made. There are alternatives to this of course, for example Region3 and Touched Event.
Example of a gun raycast
This might help you with your flamethrower script btw @MarcusDeving
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - toolHandle.CFrame.p).unit * 300)
We can reuse this method and raycast forward from the particle emitter/ the direction in which particles are moving to.
The issue is that the particles are most likely being emitted in a cone. So to achieve adequate coverage via ray casting you would need to fire many rays to approximate the cone. Is there no more efficient way?
I am going to try this out. I appreciate you posting this!
@MarcusDeving Depending on how fast the particles are, you may need to set the particles to move with the flamethrower for a better visual representation of where players will be hit, if you use this solution.