Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 rodude123 · May 29, 2014 at 11:20 AM · endless runnerleftright

endless runner game help

I have made an endless runner game for PC. I am trying make it so if you touch the left hand side you will jump and if you touch the Right hand side you will shoot. I have got an idea how to do that but I don't know how to do that. E.g. if the mouse has been clicked and it is less than 5 on the x axis then it should the player should jump or if it is more than 5 on the x axis then it should shoot. THANKS IN ADVANCED. I know this question is a little hard to understand but please help, that would be great. THANKS IN ADVANCED!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Comment
Add comment · Show 1
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
avatar image meat5000 ♦ · May 29, 2014 at 12:22 PM 1
Share

$$anonymous$$ay I ask your level of program$$anonymous$$g? I notice youve been at this for some time now. I'm curious to know what it is you are struggling with.

I admire your persistence.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by NickP_2 · May 29, 2014 at 11:57 AM

Just device the screen size in 2, for example:

 if(Input.MousePosition.x < Screen.Width / 2)
 {
     //left
 }
 else
 {
     //right
 }
Comment
Add comment · Show 2 · 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
avatar image rodude123 · May 29, 2014 at 01:17 PM 0
Share

thanks so much

avatar image rodude123 · May 30, 2014 at 09:00 AM 0
Share

I was going to put my game on to the android app store so I will put your name on it for helping

avatar image
0

Answer by konashadow · May 29, 2014 at 12:02 PM

If I understood this correctly, you want to get whether the tap occurs on the left or the right and run different code depending on which one it is. You can use Input.mousePosition to get the mouse's position on the screen, then just read the x value of that. In case my explanation didn't make sense, here's an example:

 //C#
 void Update () {
     if(Input.GetMouseButtonDown(0)) {
         Vector2 pos = Input.mousePosition;
         if(pos.x < 100) {
             Debug.Log("Jump");
         } else if(pos.x > Screen.width - 100) {
             Debug.Log ("Shoot");
         }
     }

}

Hope this helps!

Comment
Add comment · Show 2 · 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
avatar image rodude123 · May 29, 2014 at 01:17 PM 0
Share

thanks so much

avatar image rodude123 · May 30, 2014 at 09:00 AM 0
Share

I was going to put my game on to the android app store so I will put your name on it for helping

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.

Follow this Question

Answers Answers and Comments

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to Make an Endless Runner Move from track to track smoothly 0 Answers

Controlling if object is moving right or left 0 Answers

Rigidbody2d Moving up and Down but not left and right 1 Answer

Pay animation if joystick pushed to left and another if joystick is pushed to right 2 Answers

how to control player movement with ui buttons? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges