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 /
This question was closed Apr 07, 2014 at 11:24 PM by Benproductions1 for the following reason:

Not specific or technical

avatar image
1
Question by Gusic · Apr 07, 2014 at 08:09 PM · c#android2d

Script for jump when screen is touched (C#)

Hi Guys,

I am trying out a script for my player to jump when the screen is jumped, i am using the latest unity software and im making a 2d unity platform game.

Script

 using UnityEngine;
 using System.Collections;
 
 public class AndroidJump : MonoBehaviour {
     public bool grounded = true;
     public float jumpPower = 1;
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
 
             if(!grounded && rigidbody2D.velocity.y == 0) {
                 grounded = true;
             }
             if (Input.touchCount == 1 && grounded == true) {
                 rigidbody2D.AddForce(transform.up*jumpPower);
                 grounded = false;
             }
         }
     }
 
 
Comment
Add comment · Show 3
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 Infinite_Gamer · Apr 07, 2014 at 08:17 PM 0
Share

what is the question?

avatar image Gusic · Apr 07, 2014 at 08:25 PM 0
Share

The question is can you help me fix the script as it doesnt seem to be working.

Thanks

avatar image Benproductions1 · Apr 07, 2014 at 11:24 PM 0
Share

That's not a technical, specific or proper question. We aren't here to do your work for you, were here to help you do your work.

1 Reply

  • Sort: 
avatar image
1

Answer by andrew_196 · Apr 07, 2014 at 11:24 PM

if you want to regester a screen touch on a device which I presume is what you are asking you could use

     if (Input.GetMouseButtonDown(0))
 {
 Jump();
 }
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

Follow this Question

Answers Answers and Comments

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

Related Questions

Choppy Character Movement Unity 2D 0 Answers

What can I do to further optimize mobile game? (2D) 0 Answers

Multiple Cars not working 1 Answer

Why is my game(Android App) saying it i need to plug in a Gear VR to play it ? 1 Answer

UIText not updating on Android build 0 Answers


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