need help with mouse scroll wheel input
the following script is the one I'm having trouble with. when i scroll up, i should be able to see the "selectedWeapon" value icrease in the unity editor. But i don't. Is there something i'm missing? idk, please help . by the way, am I the only one whose questions dissappear after a day or so after asking?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weapons : MonoBehaviour {
public int selectedWeaopon = 0;
// Use this for initialization
void Start ()
{
if (Input.GetAxis("Mouse ScrollWheel") > 0f)
{
selectedWeaopon += 1;
}
}
// Update is called once per frame
void Update () {
}
}
Answer by CriticalAngleStudios · May 04, 2019 at 05:52 AM
Yeah, it's because you put your if statement in the start function
And besides, when you're adding 1 to a number variable (float, int, etc), you don't need to do "+= 1;" all you have to do is "++;"
Your answer
Follow this Question
Related Questions
Input.GetMouseButtonDown not working in Play mode 0 Answers
Unable to assign devices to PlayerInput whit Instantiate() 1 Answer
Need Help instantiating GameObjects in an array using the middle mouse wheel. whew. 1 Answer
How to differ between a mousedown over the map and a click on a GUI-Button 1 Answer