- Home /
unity wont detect scroll wheel
I think I have everything right on my script but it won't detect my scrolling, what am I doing wrong?
void Update ()
{
if (Input.GetAxisRaw("Mouse ScrollWheel") > 0) //Forward Scroll
{
transform.Translate(Vector3.forward * Time.deltaTime);
}
}
UPDATE: it seems to detect it on my player movement script, is it a problem that I attached the script to a camera that is a child of the player object?
Answer by Anhvuive · Aug 08, 2016 at 02:10 PM
The z axis of position will change if you use Vector3.forward in transform.Translate(Vector3.forward * Time.deltaTime); to move object to right or left you can use Vecter3.right or left
That's not the problem, it won't detect the scrolling, I tried Debug.Log so I know for sure that it's the scrolling that's wrong. I think it may have something to do with it being a child of the player object
Answer by StupidlySimple · Aug 08, 2016 at 06:09 AM
You sure it doesn't detect your scrolling?
void Update ()
{
if (Input.GetAxisRaw("Mouse ScrollWheel") > 0) //Forward Scroll
{
Debug.Log("Forward"); // See Console.
transform.Translate(Vector3.forward * Time.deltaTime);
}
}
If console spat out "Forward" when you scrolled then it detected it, and you do know that (Vector3.forward * Time.deltaTime) moves only like 2px right? If your gameObject is realistic size, 2px is barely anything.
Plus you didn't set it to Translate relative to Space.World, meaning it translating relatively to itself, which is even smaller increment.
I tested it with the debug.log before posting this thread, it doesn't work. I think it has something to do with it being a child of the player object because if I put it in my player movement script it works fine
Your answer
