Rick Posted December 27, 2013 Share Posted December 27, 2013 I'm trying to switch from 3rd person camera to first person camera which is really zoomed in over the should but I want it to behave like a first person. The below code is attached to a camera object in the scene which isn't a child of anything else. My thought was for 3rd I move the camera to the player location, rotate it, then offset it with move. When I want to go to first person my thought was move the camera to the player location, offset it with move, THEN rotate it in hopes that it would be rotating in the new over the shoulder position and not like in 3rd person. This however isn't what is happening. These both seem to be giving the same results. if self.zoomed == false then -- move the camera to the player self.entity:SetPosition(self.Character:GetPosition(true)) -- set the rotation of the camera self.entity:SetRotation(Vec3(self.cameraPitch, self.cameraYaw, 0), true) -- offset the camera self.entity:Move(self.xDistance, self.yDistance, -self.zDistance) else -- move the camera to the player self.entity:SetPosition(self.Character:GetPosition(true)) -- offset the camera self.entity:Move(self.xDistance, self.yDistance, -self.zDistance) [size=4] -- set the rotation of the camera[/size] self.entity:SetRotation(Vec3(self.cameraPitch, self.cameraYaw, 0), false) end Quote Link to comment Share on other sites More sharing options...
Rick Posted December 27, 2013 Author Share Posted December 27, 2013 I got it. It was holding the pitch and yaw from the 3rd person view still. So I reset the rotation but keep the yaw because that keeps the camera over the shoulder but by resetting the pitch before moving the camera gives me a FPS style when looking up and down, which is what I wanted. Now I'll rotate the waist by the same pitch and it should give a nice effect when in first person. Final code is: if self.zoomed == false then -- move the camera to the player self.entity:SetPosition(self.Character:GetPosition(true)) -- set the rotation of the camera self.entity:SetRotation(Vec3(self.cameraPitch, self.cameraYaw, 0), true) -- offset the camera self.entity:Move(self.xDistance, self.yDistance, -self.zDistance) else -- move the camera to the player self.entity:SetPosition(self.Character:GetPosition(true)) self.entity:SetRotation(Vec3(0, self.cameraYaw, 0)) local pos = self.entity:GetPosition(true) -- offset the camera self.entity:Move(self.xDistance, self.yDistance, -self.zDistance) -- set the rotation of the camera self.entity:SetRotation(Vec3(self.cameraPitch, self.cameraYaw, 0)) end 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.