Making a camera like how helldivers 2 has theirs

So, I’m making a shooter and I want to have a camera like how Helldivers 2 has theirs.

Here is my cade so far (not mine):

-- // Variables

-- # Services

local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local playersService = game:GetService("Players")

-- # Objects

local player = playersService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character.HumanoidRootPart
local humanoid = character.Humanoid

local camera = game.Workspace.CurrentCamera

-- // Functions

humanoid.CameraOffset = Vector3.new(0, 0, 0)
humanoid.AutoRotate = false

function RayCast(PositionA,PositionB,Params)
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = Params
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local raycastResult = workspace:Raycast(PositionA, PositionB - PositionA, raycastParams)
	if raycastResult then
		return raycastResult
	else
		return nil
	end
end

runService:BindToRenderStep("Shiftlock", Enum.RenderPriority.Character.Value, function()
	userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative

	local cameraCFrame = camera.CFrame
	local lookVector = -cameraCFrame.LookVector
	local angle = math.atan2(lookVector.x, lookVector.z)
	RayCast()
	
	humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * CFrame.Angles(0, angle, 0)
end)

In case you don’t know how helldivers camera is you can move around your character while still having your camera in a direction. when you aim, your character then turns to the direction your camera is looking.

2 Likes

Could we have video so we can get a better idea?

1 Like

Vid Link: Helldivers 2 Gameplay and Impressions… (youtube.com)
the game does contain gore and I don’t know if these people swear.

Make the character use CFrame.LookAt(), but don’t change the axis to make them look down, unless you have a tilt script. I also recommend allowing for the torso to move separately, would make it look better.

why would making the torso move separately make it look better?

If the entire character moves (like the legs) at the same time, it looks like there is no joint on the hips. Shooter games usually turn the torso independently for around 40*, and then they start moving the legs after.

This is a case of where r15 would be best ^

I see. I’m using r6 for this project though. also, I have Procedural Leg animations in game too.

the main issue I have is finding the position to put the camera.

Thats why I made this post. I know how to get them to look at the direction I need to figure out where to put the camera. Found a script. link to it: 3rd person camera lock (StarterPlayerScripts) - Creator Store (roblox.com)

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