Hello, I am trying to move my player around, I followed step by step instructions on the learning games. Keyboard keys work in “play” mode, but mouse movement does not. Please advice on how to fix input manager
Some code and the “Inspector View” of the object that should be controlled would be nice. Because we are not very good in clairvoyance. ![]()
I am very new to Unity, Please provide step by step instructions…
Also I am following the sample and they do not have any code included to move mouse. I am wondering why input manager does not recognize my mouse
Your question really is too vague for me to give you any good advice. All I can suggest is that you check that Unity is detecting your mouse. You can easily do this. Your code should include a section called Update(). If you test for your mouse there, then you should get some feedback. One way to test for your mouse is simply to report back on the location of the mouse pointer. Find the Update section and add this so it reads:
void Update()
{
Debug.Log(Input.mousePosition.ToString());
When you press play, the Console should display the position of your mouse as you move it around the screen.
If it’s doing that, then your Mouse is working perfectly but there must be something wrong with your code.
thanks that helps a little
Code in post #5 worked, so it is not issue with Unity install or input controller. Now here is my question
I followed Survival Shooter Training Day Phases - Unity Learn project and build step by step, and character moves with keyboard input no problem, however mouse movement has no affect
Any idea what did I do wrong or where should I look for a problem
I’ve not done that tutorial myself but I’m guessing that it uses a collider on the ground plane so the raycasts have something to hit when they’re projected from the point where you touch the screen. So, I’d guess the first step is to make sure you have set the scene up exactly as it’s set up in the tutorial and that it has a collider on the ground and that everything is named correctly.
Thanks for all your help… I did miss the step n the environment setup.
It is working now
I made the mistake when watching the setting up the environment video to click the drop down for tags rather than levels and when I didn’t see the floor level under tags I added the floor like a dummy causing the mouse to not work and not report errors. *blush
can anyone help me i have the same problem here…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] private float _Speed = 2f;
[SerializeField] private Camera _Camera = null;
private CharacterController _CharacterController = null;
private Vector3 _Move = Vector3.zero;
private float _CurrentRotationX = 0f;
private float _CurrentRotationY = 0f;
private float _MouseX = 0f;
private float _MouseY = 0f;
private float _CameraRotationSpeed = 100f;
private void Start()
{
_CharacterController = GetComponent();
}
private void Update()
{
float horizontal = Input.GetAxis(“Horizontal”); // -1f → 1f
float vertical = Input.GetAxis(“Vertical”);
Input.GetAxis(“Mouse X”);
Input.GetAxis(“Mouse Y”);
_Move.x = horizontal;
_Move.z = vertical;
_CharacterController.Move(_Move * (_Speed * Time.deltaTime));
}
private void LateUpdate()
{
float cameraSpeed = Time.deltaTime * _CameraRotationSpeed;
_CurrentRotationX += _MouseX * cameraSpeed;
_CurrentRotationY += _MouseY * cameraSpeed;
_Camera.transform.rotation = Quaternion.Euler(_CurrentRotationX, _CurrentRotationY, 0f);
}
}
![]()
If you’re on windows cpu check power management settings are not set to power saver mode as this will stop the mouse from functioning during play mode.
I am having a problem where the player cannot click buttons or type in input fields. I am also new to unity. Please help
Please don’t necro-post to eight year old threads for vague completely-unrelated things like “problem where the player cannot click”
Instead, follow these steps for success:
How to report your problem productively in the Unity3D forums:
This is the bare minimum of information to report:
- what you want
- what you tried
- what you expected to happen
- what actually happened, especially any errors you see
- links to documentation you used to cross-check your work (CRITICAL!!!)
If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: https://discussions.unity.com/t/481379
If you have no idea what is happening, fix that first. Here is how:
What is often happening in these cases is one of the following:
- the code you think is executing is not actually executing at all
- the code is executing far EARLIER or LATER than you think
- the code is executing far LESS OFTEN than you think
- the code is executing far MORE OFTEN than you think
- the code is executing on another GameObject than you think it is
- you’re getting an error or warning and you haven’t noticed it in the console window
To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
- is this code even running? which parts are running? how often does it run? what order does it run in?
- what are the values of the variables involved? Are they initialized? Are the values reasonable?
- are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)
Knowing this information will help you reason about the behavior you are seeing.
You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as Debug.Log("Problem!",this);
If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.
You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.
You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.
You could also just display various important quantities in UI Text elements to watch them change as you play the game.
If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: https://discussions.unity.com/t/700551 or this answer for Android: https://discussions.unity.com/t/699654
Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.
Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:
https://forum.unity.com/threads/coroutine-missing-hint-and-error.1103197/#post-7100494
You must find a way to get the information you need in order to reason about what the problem is.