- What do you want to achieve?
Shoot a fireball in a line, in the direction of the players mouse, about 70 units out, while the shoulder lock camera is enabled. This needs to work even if I shoot at empty sky (no click surface) because in my game a big part is being able to target flying enemies to attack.
- What is the issue?
If I have the lock cursor camera turned off I fire a tween to shoot my fireball and it works great (fireball shoots from my position in a lookvector away from my humanoidrootpart), however if I have the lock camera turned on I want the projectile to shoot towards the mouse, but it just sits in front of the player.
- What solutions have you tried so far?
Hereâs some server code: If shoulderCam is false the tween works great⌠itâs the tween in the else thatâs failing.
if shoulderCam == false then
tweenservice:Create(fireball, TweenInfo.new(3, 0, 0), {CFrame = player.Character.HumanoidRootPart.CFrame + player.Character.HumanoidRootPart.CFrame.lookVector * 70, Transparency = 1}, Enum.EasingStyle.Quint,Enum.EasingDirection.Out):Play()
else
tweenservice:Create(fireball, TweenInfo.new(3, 0, 0), {CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, mousePosition).LookVector * 70, Transparency = 1}, Enum.EasingStyle.Quint, Enum.EasingDirection.Out):Play()
end
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that itâs easier for people to help you!
Maybe it has to do with how I am getting âmousePositionâ? Here is how I retrieve that (on the client):
-- Detect shoulder cam vs regular mouse use
local shoulderCam = false
local mousePosition = nil
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
shoulderCam = true
local mouse = player:GetMouse()
local mouseHit = mouse.Hit
local result = RayResult(mouseHit.Position.X, mouseHit.Position.Y)
mousePosition = result.Position
end
and RayResult:
local function RayResult(x, y)
local parameters = RaycastParams.new()
parameters.FilterType = Enum.RaycastFilterType.Exclude
parameters.FilterDescendantsInstances = {workspace.Scenery, workspace.Plots, player}
local unitRay = camera:ScreenPointToRay(x, y)
return workspace:Raycast(unitRay.Origin, unitRay.Direction * 500, parameters)
end
The shoulderCam and mousePosition are passed to the server via:
script.RemoteEvent:FireServer(shoulderCam, mousePosition)
Iâve tried playing with the raycast, the distance, also, converting from the Vector3 to the CFrame in the tween might be off, Iâm just getting into that.
Should be all relevant code. Let me know if you all see something out of line. Thanks!