Infection spread parts

Hello, i making an infection game and i want to make parts spread from part in the middle and also spread to the walls, how i can make it?
dc7a54a56ba2073d67626f4d01ebb08e

1 Like

You can utilize VectorForce, so you can duplicate the part, set the parent to workspace, and add vectorforce in the specific direction that you want. Or, you can also do something like part:ApplyImpulse(Vector3.new(10,0,0)) or something along these lines. It really depends on what you need.

i want it to spread from one part to different sides like infecting blocks and make it able to spread at the walls and roof, i tried alot of things to make it spread to wall but still can’t find solution

What are these red points in the image. . . . . . . . . . . .

Ok, what have you tried so far?

1 Like

i made script that has start point with 1 object value, object value is lastpoint.when part spawns , spawned part becomes value of object value and from this lastpoint parts spawning in different directions, i just can’t understand how to make it go spread to the walls and roof. i tried raycast but i didn’t really understood how to make it with raycasting.

if arrows , its just direction of spreading. if red points on model in middle, idk its just a model

Here is my suggestion. Look at models of guns that have similar mechanisms. In my case, I looked at the hyperlaser gun. This is an excerpt of the script:

local ShotCFrame = CFrame.new(FiringPoint, target)

local LaserShotClone = BaseShot:Clone()
LaserShotClone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.velocity = ShotCFrame.lookVector * Speed
BodyVelocity.Parent = LaserShotClone

What you can do is abstract the main principles behind this mechanism and apply it to yours. In the gun’s case, what it does to shoot out the bullet in the linear fashion that you want is it clones the part is needs as the bullet (LaserShotClone), positions it in some manner, and then adds velocity to it, based on the firing point and target positions.

You already know the firing point position, in your case, the red things in your model, and you can figure out the target by using ray casting. Or, you can just add body velocity in a certain direction, which is much easier.