3D FPS to 2D mouse
Alright so I have this game where in the first scene the player is a first person camera that moves with WASD and looks around with the mouse. When I exit the scene, There is a 2D, flat canvas where the player clicks a button and the game continues, but the mouse isn't appearing on the 2D scene. I know it has something to do with the mouse being used to look around on the first scene but I don't know how to fix it. I need to get this game done as soon as possible so any responses help!
Answer by Jessespike · Aug 21, 2016 at 10:40 AM
Try setting the cursor. Add this to a script in the menu scene.
void Start() {
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
Im getting several errors with the code, @Jessespike
Assets/scripts/mouse.cs(7,30): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/scripts/mouse.cs(6,10): error CS1031: Type expected
Because you have no idea how program$$anonymous$$g in Unity works. No offence, but you have to learn to code, the community can not do the work for you.
Here is your code. Create the script (the name of the script should match the name of the class 'CursorUnlocker') and attach it somewhere in the scene in which you want to get mouse pointer visible. I'd recommend to create a new GameObject with the same name as the script.
using UnityEngine;
public class CursorUnlocker : $$anonymous$$onoBehaviour
{
void Awake()
{
Cursor.lockState = CursorLock$$anonymous$$ode.None;
Cursor.visible = true;
}
}
@incorrect Thanks the code worked. This game I'm making is for a school project and I'm literally doing it to learn code. I'm familiar with JS but C# is brand new to me. Thanks anyway for the help!