- Home /
how to make a first person character controller
I would like to know how or at least where to start making a custom controller, because whenever i use the unity prefab controller I cant lock/unlock cursor nor can I change the visibility. any help would be appreciated :D
The two issues you mention have nothing to do with the CharacterController or Character$$anonymous$$otor scripts. What exactly are your problems?
i have an inventory that when i open it (press i) it change visibility of the cursor and changes its lockstate
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class invetory : $$anonymous$$onoBehaviour {
public GameObject Inventory;
public string InventoryOpen = "false";
// Use this for initialization
void Start () {
Inventory.SetActive (false);
}
// Update is called once per frame
void Update () {
if (InventoryOpen == "false" && Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.I)) {
Inventory.SetActive (true);
InventoryOpen = "true";
Cursor.visible = true;
Cursor.lockState = CursorLock$$anonymous$$ode.None;
}
else {
if (InventoryOpen == "true" && Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.I)) {
Inventory.SetActive (false);
InventoryOpen = "false";
Cursor.visible = false;
Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
}
}
}
} `
Have you made sure that no other scripts in your scene affect the lockstate and cursor visibility? Have you tried inserting Debug.Log lines into your code to see if the lines in Update() are reached?
Answer by cameronb_unity287 · Mar 04, 2019 at 04:00 PM
https://www.youtube.com/watch?v=HIyxpl-Yahs this is what I used
Your answer
Follow this Question
Related Questions
How can I add smooth movement to a RigidBody? 2 Answers
Hit detection with unity character controler 0 Answers
Problem with the standard mouselook script 0 Answers
First-Person Controller with Head Bobbing 0 Answers
Advanced Character Motor? 1 Answer