How do i make bullet time travel using raycast. The issue is the raycast travels instantly
Theres multiple ways of doing it aslong as u have the start and end position of the bullet.
You could lerp it using this function
function lerp(a, b, c)
return a + (b - a) * c
where a is the start, b is the end and c is the time position
Edit: Or just do :lerp(goal,alpha)
Or you could tween it using the tweenservice
You could even use forces if you want to.
I quite don’t understand this function. Can you explain more?
Basically you input two positions A and B, and the function gets u all the positions between those two points based on the time C that you input.
like this (Mouse - Origin) * 1 ?
You’d have to do a for loop where you go from i = 0 to i = 1 and use i as the c value, and the position of the bullet would be set to lerp(origin,mouse,i)
In this case I recommend going for the tweenservice or the module that @FerbZides uggested though as they’re smoother and easier to use.
I think you pinged the wrong person.
Yep sorry about that! Ment to tag FerbZides
Also, can you explain that lerping function? I don’t understand.
me too i don’t really understand that function either
Its basically the same as doing Vector3:lerp(goal,alpha) which just moves a vector3 position to the goal using the alpha value, so for example if u use 0.5 for the alpha then you get half way from the vector 3 to ur goal, if you use 1 then you get from the vector3 to the goal and so on.
I propably shouldve just mentioned this instead of a custom function, I forgot you could do that
To avoid any confusion just go with the tweenservice, its better for this.
Can we like have a source code example?
A really simple solution could just be to add a delay on the raycast by calculating the distance. Of course this wouldn’t calculate for the velocity changes of the bullet while traveling.
i want it be as accurate by delaying how fast the raycast goes
man I feel you, im tryna figure out the same thing nothing helping me right now bro