• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by yohanrw · Oct 20, 2013 at 01:51 PM · rigidbodymousewheel

Listening to the "Mouse Scroll Wheel"

Hello,

I need to listen to the mouse scroll view, and if the user scrolled up, increase the "Fire Power". Following is my code.

 using UnityEngine;
 using System.Collections;
 
 public class Shooter : MonoBehaviour {
     
     public Rigidbody bullet;
     public float power = 1500f;
     public float moveSpeed = 25f;
 
     
     // Update is called once per frame
     void Update () 
     {
         float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
         float v = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
         
         transform.Translate(h,v,0);
         
         if(Input.GetButtonUp("Fire1"))
         {
             Rigidbody instance = Instantiate(bullet,transform.position,transform.rotation) as Rigidbody;
             
             Vector3 fwd = transform.TransformDirection(Vector3.forward);
             
             instance.AddForce(fwd*power);
         }
         else if(Input.GetButtonUp("Mouse ScrollWheel"))
         {
             power = power * 2;
         }
     
     }
 }


But, this "MouseScrollWheel" part seems not working. What am I doing wrong?

Please help.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by meat5000 · Oct 20, 2013 at 01:54 PM

http://answers.unity3d.com/questions/13485/implementing-the-scrollwheel.html

I think it's all here in this post

Input.GetAxis("Mouse ScrollWheel") in a nutshell

Must use GetAxis

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

My bullet wont move forward 1 Answer

Error in script 1 Answer

How to shoot to where "Mouse" is pointing? 1 Answer

Click To Move Character Walks Straight Through Objects 1 Answer

Unity 3d Elevator Script Not Working Properly 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges