How would i be able to calculate a cframe so a viewmodels line of sight matches a ray in the center of the screen

hello im rewriting my fps game i did last year, in the previous version i had a problem when not aiming down sights the bullets trajectory would just go whitout being on the center, the solution at the time was making the bullet come out of the center of the screen which was really weird,
this time i want to make it so the actual viewmodel aims at the center of the screen depending on distance, the theory i want to try this time is raycasting and aiming the gun at the position the ray hit, yes ive tried cframe.lookat but the viewmodel would just go out of control and spin

ive searched many times on the dev forum and couldnt really find anything that could help me

Most games raycast damage from the center of the screen like you’ve done before, but draw the bullets coming from the gun towards the point the player clicked on. I highly recommend doing it that way.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.