#looking around system
1 messages · Page 1 of 1 (latest)
hi
ok so
so uh this is the code:
public void playerMouse()
{
float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
xrot -= mouseY;
xrot = Mathf.Clamp(xrot, -90f, 90f);
cam.transform.localRotation = Quaternion.Euler(xrot, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
}
uh
so float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
gets the input
alright
oh
ah
so
public void playerMouse()
{
float mouseX = Input.GetAxis("Mouse X") * sensitivity;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity
xrot -= mouseY;
xrot = Mathf.Clamp(xrot, -90f, 90f);
cam.transform.localRotation = Quaternion.Euler(xrot, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
}```
and this xrot -= mouseY;
mhm
yeah
alright
this comes from trial and error
if its +, it would be flipped
ah
xrot = Mathf.Clamp(xrot, -90f, 90f);
this clamps the xrot
cam.transform.localRotation = Quaternion.Euler(xrot, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
mhm
these just rotates the player and cam
yeah
yup
how would i fix these
declare the variables, put a semicolon in float mouseY = Input.GetAxis("Mouse Y") * sensitivity
declare variables declare variables declare variables declare variables declare variables declare variables declare variables declare variables
nonono
hm
just do public float xrot;
whaaa
cam.transform.localRotation = Quaternion.Euler(xrot, 0f, 0f);```
hm
yes
did you make the cam a gameobject
the cam variable
?
show ur full code
ok
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
//public
public CharacterController controller;
public float sensitivity = 3f;
public float xrot;
public float cam;
public float speed = 3f;
public float gravity = -23f;
public float jumpHeight = 3f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
//bool
bool running;
bool isGrounded;
//vector3
Vector3 velocity;
void Update()
{
if (Input.GetKey(KeyCode.LeftShift))
{
running = true;
}
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
if (isGrounded && velocity.y < 0)
{
velocity.y = -7.3f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
if (running == true && isGrounded)
{
speed = 6f;
running = false;
}
else
{
speed = 3f;
}
Vector3 run = move * speed * Time.deltaTime;
controller.Move(run);
if (Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * gravity * -2f);
}
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
public void playerMouse()
{
float mouseX = Input.GetAxis("Mouse X") * sensitivity;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity;
xrot -= mouseY;
xrot = Mathf.Clamp(xrot, -90f, 90f);
cam.transform.localRotation = Quaternion.Euler(xrot, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
}
}
why the frick is the camera a float lmao
yes lol
please use a proper ide
ide?
alr 1sec
you will get autocorrect
ah
if you get autocorrect, you will get the reccomendation Transform
alrigtht
it wont pop up
yes