Hello, so i have this scripts that shoots a part to where the players mouse is, but i want to change it to be in the direction of the camera. How do i do that?
local camera = workspace.CurrentCamera
local startPosition = Vector3.new() --startPosition is probably going to be where you shoot the part from
local direction = (startPosition - camera.CFrame.Position).Unit --this is the direction to the camera from startPosition.
After reading your code it’s probably better for you to do this
local cameraPosition = camera.CFrame.Position --if this is in the server, you're gonna have to get the camera position from the client.
bullet.CFrame = CFrame.lookAt(headPos * Vector3.new(0,0,-7), cameraPosition)
It’s better to use CFrame.lookAt() instead of CFrame.new() when you want something to look at a position.
you should make the bullet’s cframe the player’s camera if its a first person game, if you have it at the shoot position then it will originate at the throw position
But another really big reason of why im trying to use camera instead of mouse even though mouse works perfectly, is because im also trying to make this system for mobile, but its kind of difficult with mobile and mouse because it gets the spot the player touched last on the screen. But i always want it to be in the middle of the screen for mobile, just like this shift lock system
I tried making another dev forum post about this but no one responded
Ok so anyways, idrk, for those who are looking at this hoping for a resolved issue. I basically had set a camera offset for my costom shift lock system.