I want to make custom projectile physics for my gun game, because Roblox’s physics engine is kind of weird and I need to resort back to it. How would I make the parabolic path and make the projectile move along the arc? Is there also a way I could see the projectiles destination before it launches? Thank you!
Something with using a pre-made module doesn’t feel rewarding. I want this entire game to include my own assets. I also tried fastcast and it wasn’t up to my standards. Thank you though for the reply!
The principle of it is that you’re using a formula which takes an initial position, velocity and gravity to calculate the projectile’s position at any given moment using time as a variable, with this you can raycast for collisions each frame from the previous position to the current frame’s position using a deltatime accumulator.
Thank you for the reply!
Another thing I briefly mentioned—how would I make the projectile move? I know a new programmer would say to make a bezier curve and tween it, but I don’t think you could use tweening for a curve. How else would I move it?
you don’t need to tween in a perfect curve, like @Ascyius said with getting the position for every given moment and doing those checks and whatnot, just have it tween from the start point to that new end point. Depending on how often you update the position, it will give a smoother curve, but you don’t need to update it that often for it to look perfect to your eyes.
Wouldn’t doing those checks every frame cause it to lag? I want there to be a downwards acceleration due to gravity. My main issue now is just moving the projectile with a custom physics engine.
100% do not do it every frame lol. if you used a formula, it would set the position based on the variable time, which means that you can set time to whatever you want, which means you can update it however often you want. He didn’t really give a formula, but if you do a step by step model instead of one formula, you can still customize how much time it calculates at once.
I can’t imagine gravity is that big of an effect with guns. Each update would give a start and end point where you can do a check and a tween, you want the distance of those two points to be as big as possible without it having any noticeable impact to any gravity, wind, any other calculations that would be done. (regardless, the path will be the same, its just the smoothness of the arc, all at the cost of performance.)
Is there a more efficient way to smoothly move the bullets without tweens? I want to add constant deceleration on the projectile, because although gravity may not have a big impact on bullets, you will mainly be shooting long-range weapons in long-range scenarios, so that gravity may have an impact there.
I believe tweens are more efficient than if you tried to make your own tween system using for loops or anything. Tweens are the best, unless you are fine with using some loop that isn’t as smooth as a for loop and like moves it a few studs at a time , which would be slightly more efficient I believe.
If this is some long range shooting game, it seems like there wouldn’t be too many bullets being fired anyway, so I wouldn’t stress too hard about it all.
have a velocity that you add to the actual position constantly, then you can modify the velocity with an acceleration
fastcast already does this even with raycast checks and it runs well for hundreds of bullets at the same time
this approach also follows the kinematics equations so you can predict the arc
edit: also tweens only go in a straight line
edit: i already implemented this with the arc prediction for my game it works
I think you kinda skimmed through the whole conversation where I talked about that, but whatevs