How do I slow a raycast down?

I’m working on a gun system right now, and I have been attempting to figure out how to slow the raycast down so It doesn’t just immediately hit the player you are shooting at.

How would I go about doing this? I would prefer to use a raycast as it is the type of gun I am leaning towards.

1 Like

Huh? Do you mean slow down the speed of the bullet or do you mean delay your raycast?

2 Likes

That would have to be done with Projectiles, which would give you more control of the weapons, but might have issues with hit detection.

Also, Bullets are fast, if you want the bullet to not immediately hit the target, you would have to be shooting at a very far away target, and also account for the power of the weapon (eg: pistol is not as powerful as a rifle, therefore will not shoot a very powerful bullet, making it slower, and doing less damage), which there you can choose to “delay” the raycast, by first calulating the distance of your object, and then accelerating the speed of the bullet, or the delay of the raycast, to hit the target.

3 Likes

To slow it down, so the raycast doesn’t hit the target immediately, it has travel to it.

1 Like

That is true, but I meant mainly for long-range, as if its quite far out and a user were to shoot, it would immediately reach them.

1 Like

Use the cool module called FastCast, this module splits a raycast into multiple raycasts and slows them down with a speed parameter and multiple others

(not sponsored btw)

2 Likes

So you want it to immediately reach them, but you want the raycast to slow?

I don’t understand what you mean but at surface level adding a task.delay would help

I think that he is trying to say, instead of the raycast on the gun that hits the player instantly, he wants the player to be damaged when the bullet touches him

1 Like

I don’t think that relates to anything he said about damage, and if so that is an easy solution to just damage them instead of killing them.

1 Like