More accurate hit detection for kinematic projectile physics

I am using a modified version of the displacement formula to simulate projectile physics.

local function x(x0, v0, a, t)
	return x0 + v0 * t + 0.5 * a * t^2
end

local function v(v0, a, t)
	return v0 + a * t
end

function physics:step(time)
	self.position = Vector3.new(
		x(self.position.X, self.velocity.X, self.acceleration.X, time),
		x(self.position.Y, self.velocity.Y, self.acceleration.Y, time),
		x(self.position.Z, self.velocity.Z, self.acceleration.Z, time)
	)
	
	self.velocity = Vector3.new(
		v(self.velocity.X, self.acceleration.X, time),
		v(self.velocity.Y, self.acceleration.Y, time),
		v(self.velocity.Z, self.acceleration.Z, time)
	)
end

i have a wrapper object which is supposed to add more functionality to the physics module.

local _physics = self._physics
	
	_physics.acceleration = self.acceleration
	_physics.position = self.position
	_physics.velocity = self.velocity
	
	_physics:step(time)
	
	local raycastResult = workspace:Raycast(self.position, _physics.position - self.position, self.raycastParams)
	
	if raycastResult then
		
	end

initially, for collisions i thought about using raycasts but then i realised this would not work if the time i step by is too large.
The obvious solution is to break down a large step to smaller increments and update the physics that way.
however, I want to know if there is any way that I could skip this? is there any way I can simulate collisions without having to raycast tiny steps all the time?

Try raycasting backwards from the tip of the projectile the amount it would move in one increment.

Say it travels 4 studs/increment. If you raycast backwards from the tip of the bullet 5 studs (to be safe) then if the bullet passes through an item it should register the hit fairly accurately.

that is still raycasting multiple times. I was thinking to break things up into simply their volumes and checking the position values for the physics object to check at what time would it reach an intersection. this however sounds very complicated and so im wondering if it even is feasible at all.

Yes, since if you have moving objects it’d be hard to predict where their volumes should be when they might intersect.
For example if you had a fast moving object that changed direction suddenly into the path of the projectile before it was expected then it’d miss the object.
You could do GetPartsInPart, but again, you’d have to check any one of these methods each step to see if there would be, or is, a hit.

it doesnt matter that. i just need the projectile to bounce accordingly. its simply just a point being pushed through 3d space.

I have a feeling we could maybe implement “curved raycasts”. Currently, raycasts are limited to linear motion due to how much less complex those math equations are to compute. We will have to define the plane/s in which we will be checking for intersections. The issue is that we will be very limited to what we can do since roblox doesn’t allow us (but should) to see further information into the geometry of objects and meshes (WHICH THEY SHOULD).

Your can design your functions to work with vectors instead of numbers. This would allow you to adjust the position and velocity of the object in two lines of code, with zero code duplication

i dont understand what you mean. the way the code is right now is fine.