"Head/Waist follow Mouse/Camera script" Code Answer's

You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "Head/Waist follow Mouse/Camera script" answered properly. Developers are finding an appropriate answer about Head/Waist follow Mouse/Camera script related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like Head/Waist follow Mouse/Camera script. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on Head/Waist follow Mouse/Camera script. 

Head/Waist follow Mouse/Camera script

By UndefinedUndefined on Oct 18, 2020
--[[
	[Head/Waist Follow Mouse/Camera Script.]
	[Works with both R6 and R15, lets you turn your character's head and waist towards your mouse/camera.]
	[Scripted by Rigby#9052 on Discord]
--]]

wait()

--[Pre-Funcs]:

local Ang = CFrame.Angles	--[Storing these as variables so I dont have to type them out.]
local aSin = math.asin
local aTan = math.atan

--[Constants]:

local Cam = game.Workspace.CurrentCamera

local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Body = Plr.Character or Plr.CharacterAdded:wait()
local Head = Body:WaitForChild("Head")
local Hum = Body:WaitForChild("Humanoid")
local Core = Body:WaitForChild("HumanoidRootPart")
local IsR6 = (Hum.RigType.Value==0)	--[Checking if the player is using R15 or R6.]
local Trso = (IsR6 and Body:WaitForChild("Torso")) or Body:WaitForChild("UpperTorso")
local Neck = (IsR6 and Trso:WaitForChild("Neck")) or Head:WaitForChild("Neck")	--[Once we know the Rig, we know what to find.]
local Waist = (not IsR6 and Trso:WaitForChild("Waist"))	--[R6 doesn't have a waist joint, unfortunately.]

--[[
	[Whether rotation follows the camera or the mouse.]
	[Useful with tools if true, but camera tracking runs smoother.]
--]]
local MseGuide = false
--[[
	[Whether the whole character turns to face the mouse.]
	[If set to true, MseGuide will be set to true and both HeadHorFactor and BodyHorFactor will be set to 0]
--]]
local TurnCharacterToMouse = false
--[[
	[Horizontal and Vertical limits for head and body tracking.]
	[Setting to 0 negates tracking, setting to 1 is normal tracking, and setting to anything higher than 1 goes past real life head/body rotation capabilities.]
--]]
local HeadHorFactor = 1
local HeadVertFactor = 0.6
local BodyHorFactor = 0.5
local BodyVertFactor = 0.4

--[[
	[How fast the body rotates.]
	[Setting to 0 negates tracking, and setting to 1 is instant rotation. 0.5 is a nice in-between that works with MseGuide on or off.]
	[Setting this any higher than 1 causes weird glitchy shaking occasionally.]
--]]
local UpdateSpeed = 0.5

local NeckOrgnC0 = Neck.C0	--[Get the base C0 to manipulate off of.]
local WaistOrgnC0 = (not IsR6 and Waist.C0)	--[Get the base C0 to manipulate off of.]

--[Setup]:

Neck.MaxVelocity = 1/3

-- Activation]:
if TurnCharacterToMouse == true then
	MseGuide = true
	HeadHorFactor = 0
	BodyHorFactor = 0
end

game:GetService("RunService").RenderStepped:Connect(function()
	local CamCF = Cam.CoordinateFrame
	if ((IsR6 and Body["Torso"]) or Body["UpperTorso"])~=nil and Body["Head"]~=nil then	--[Check for the Torso and Head...]
		local TrsoLV = Trso.CFrame.lookVector
		local HdPos = Head.CFrame.p
		if IsR6 and Neck or Neck and Waist then	--[Make sure the Neck still exists.]
			if Cam.CameraSubject:IsDescendantOf(Body) or Cam.CameraSubject:IsDescendantOf(Plr) then
				local Dist = nil;
				local Diff = nil;
				if not MseGuide then	--[If not tracking the Mouse then get the Camera.]
					Dist = (Head.CFrame.p-CamCF.p).magnitude
					Diff = Head.CFrame.Y-CamCF.Y
					if not IsR6 then	--[R6 and R15 Neck rotation C0s are different; R15: X axis inverted and Z is now the Y.]
						Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Ang((aSin(Diff/Dist)*HeadVertFactor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y*HeadHorFactor, 0), UpdateSpeed/2)
						Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Ang((aSin(Diff/Dist)*BodyVertFactor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0), UpdateSpeed/2)
					else	--[R15s actually have the properly oriented Neck CFrame.]
						Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Ang(-(aSin(Diff/Dist)*HeadVertFactor), 0, -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y*HeadHorFactor),UpdateSpeed/2)
					end
				else
					local Point = Mouse.Hit.p
					Dist = (Head.CFrame.p-Point).magnitude
					Diff = Head.CFrame.Y-Point.Y
					if not IsR6 then
						Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Ang(-(aTan(Diff/Dist)*HeadVertFactor), (((HdPos-Point).Unit):Cross(TrsoLV)).Y*HeadHorFactor, 0), UpdateSpeed/2)
						Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Ang(-(aTan(Diff/Dist)*BodyVertFactor), (((HdPos-Point).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0), UpdateSpeed/2)
					else
						Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Ang((aTan(Diff/Dist)*HeadVertFactor), 0, (((HdPos-Point).Unit):Cross(TrsoLV)).Y*HeadHorFactor), UpdateSpeed/2)
					end
				end
			end
		end
	end
	if TurnCharacterToMouse == true then
		Hum.AutoRotate = false
		Core.CFrame = Core.CFrame:lerp(CFrame.new(Core.Position, Vector3.new(Mouse.Hit.p.x, Core.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
	else
		Hum.AutoRotate = true
	end
end)

--=========This Script Is Originaly Produced By==============
--============== Rigby#9052 ========================
--==============Used & Tested by:(JUB0T)==============
--Dont change the original owners

Add Comment

0

Head/Waist follow Mouse/Camera script

By Annoying AntAnnoying Ant on Jun 03, 2021
free fire

Add Comment

0

All those coders who are working on the Whatever based application and are stuck on Head/Waist follow Mouse/Camera script can get a collection of related answers to their query. Programmers need to enter their query on Head/Waist follow Mouse/Camera script related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Head/Waist follow Mouse/Camera script for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of Head/Waist follow Mouse/Camera script while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "Head/Waist follow Mouse/Camera script". Visit this developer's friendly online web community, CodeProZone, and get your queries like Head/Waist follow Mouse/Camera script resolved professionally and stay updated to the latest Whatever updates. 

Whatever answers related to "Head/Waist follow Mouse/Camera script"

View All Whatever queries

Whatever queries related to "Head/Waist follow Mouse/Camera script"

Head/Waist follow Mouse/Camera script how to make a ui follow your mouse Smooth Camera script roblox studiio unity fps camera rotation script linked set follow fofo //File: lineFollow3.ic //Robust 04/18/2012 //Purpose: Brute force to have rover follow a line (~2.5 inches wide) All greedy algorithms follow a basic structure net_pivot = df.pivot_table(values = 'Mean Temp (C)', columns ='season', index = 'Year', aggfunc = 'mean') net_pivot.head() head -n head head royce school delete commit head flutter textformfield how to go head is head of linked list null camera not working ios info plist use camera permission Camera permission how to make event take camera in flutter Roblox Main Menu Camera Get camera position unity Camera Permission in Android youtube video about looking inside the lens of a canon camera flutter google map change camera position how to let the player move by the camera direction good wired backup camera monitor under $100 how to add players camera button camera code how to define connected camera as media source to webrtc android how much does it cost to fix a computer camera unity change camera scale third person shooter camera code unity unity3d opencv and reolink camera unity attach camera to gameobject struct Camera; camera for recording cheap rnimagepicker error This library does not require Manifest.permission.CAMERA, if you add this permission in manifest then you have to obtain the same. how to hover mouse over an element in selenium print mouse click x and y get htm,l element under mouse godot mouse position godot get mouse position raycast jquery mouse hover method sdl2 mouse click close mat select panel when mouse leaves set mouse over colors for button wpf sfml hide mouse wireless mouse takes a while to respond Mouse blocking on screen border when dragging window how to make character rotate to the direction of the mouse in unity2d get x and y of mouse uinty how can i change the color of the selection through mouse in fthe vscode godot check if mouse button was just pressed best material for mouse pad a-frame mouse interaction forward and back mouse buttons not working in vmware ubuntu Bind mouse wheel jump csgo what is Razor Script disable script in unity godot first person controller script button script visual studio 2019 google script last row sprite unity script how to know username apps script nmap -Pn --script vuln ipaddr minecraft server start batch script Refused to execute inline script because it violates the following Content Security Policy directive How to make a script that spawns parts what to do if script fails js jquery include external script terraform script to create s3 bucket how to write a script to render in iframe init script app script for google forms to email app hypertext preprocessor script Account age blacklist script for roblox script dir bash travis allow_failures script Difference between Test case and Test script? load test script locust roblox studio change size script How to make a cash giving script execute a menu command from script unity how to make a death animation script Brick spawner script for roblox studio find duplicates apps script html5 script external How to make a bubble chat script part spawner script for roblox studio dontdestroyonload script zsh print each line of script btn script t rex how to call a void from difrent script obs studio use script npm run build npm ERR! Missing script: "build" for firebase unity change button onclick in script test case vs test script rest assured script how to get the script of fontawesome how to make a creator joined script TypeError: Cannot read property 'RecId' of undefined app script script generate tracking number ups by post how to make a 24 minute day night script npm ERR! missing script: build:dev bash script cheat sheet run python script in kubernetes how to make a owner joined script quizlet In converting an entrepreneurial business script into an enterprise value chain, the financing process of the value chain is usually made up of two different scenes what will you do if test script fails long query running script teste google script photoshop script create prompt How to amke a Gamepass script in roblox studio 2020 half life bhop script nickaname and tag unity and pun2 script bs4 get text from script tag how to run a script in crontab every day mikrotik script check ip public activate pane apple script test scenario, test case and test script boot up batch script pop cat script how to make a player join / left script windows batch script to run application in background can we script test case without object repository photoshop script open file dialog how to save script in another file How to make a rain script photoshop script confirmation prompt bash script in array slow query script app script comparison existing data hack discord script script and style for admin menu How to amke a death animation script keynote Present Keynote slideshow: display script of similar information that only you can see: photoshop script: save as jpg bash script exec blocks Slow walk script dockerfile chmod: changing permissions of './script.sh': Operation not permitted unity 2d platformer movement script rigidbody bash script speichern from speed test in influxdb batch script delete files older than 30 days exemples de script iptables total time taken by script how to send mail in pdf format in netsuite using script roblox kick player script script deferred how to get the player character roblox script script to get pem expiration date unity player move script terraform script to launch aws instance launch regex to filter login script injection npm run script with arguments glances intsallation script autoit check if autoit script is running detect script in pdf apps script convert docx to doc entity framework generate script google app script when user uses on edit protected range r library from conda environment batch job bash script first person movement script for godot

Browse Other Code Languages

CodeProZone