First Person Script

Hi So I’m working on this Horror game and it’s not that big but I have some problems with the Player Script. I wanted some help on how I could make the player rotate.
Here’s my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Playermovement : MonoBehaviour {
public float moveSpeed;

// Use this for initialization
void Start()
{
moveSpeed = 15f;
}

// Update is called once per frame
void Update()
{
transform.Translate(moveSpeed*Input.GetAxis(“Horizontal”)Time.deltaTime,0f,moveSpeedInput.GetAxis(“Vertical”)*Time.deltaTime);
}
}

Since you haven’t tried anything yet, here’s an excellent tutorial on the subject:

Ýeah but people in the comments are saying that it’s not working for them.

Not everyone is 100% capable of following instructions ;D. Have you tried it for yourself? Are you running into some specific problem?

Nope haha but I think it depends on the Unity Version idk they update things lol

That tutorial is less than a year old. I assure you none of the things in that video have changed in Unity. I’ll be glad to help you further if you try it out and run into problems.

Alright thank you :slight_smile:

So There’s a problem with the rotation.
Here’s my Mouse Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseScript : MonoBehaviour
{

public float mouseSensitivity = 100f;

public Transform playerBody;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis(“Mouse X”) * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis(“Mouse Y”) * mouseSensitivity * Time.deltaTime;

playerBody.Rotate(Vector3.up * mouseX);
}
}

Nvm Just figured it out haha

Okay so I did the rotation script and I’m now on the Key script but everytime I try to move with WASD it just flies up into the air
Here’s my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovementScript : MonoBehaviour
{
public CharacterController controller;

public float speed = 12f;

// Update is called once per frame
void Update()
{
float x = Input.GetAxis(“Horizontal”);
float z = Input.GetAxis(“Vertical”);

Vector3 move = transform.right * x + transform.forward * z;

controller.Move(move * speed * Time.deltaTime);
}
}

Okay and Now the player has epileptic seizures

Do you have any other scripts attached to this object or its parent or children? For example your original movement script from your first post?

Nope here’s some screenshot’s:

6208827--682092--screenshot 121212.PNG
6208827--682095--screenshot 11.PNG

Oh It was the capsule collider not set on trigger haha

If you’re following the tutorial I shared there shouldn’t be other colliders or Rigidbody on the character at all.