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
-1
Question by john 2 · Aug 20, 2010 at 01:12 AM · javascriptjumpjumping

how to jump with 2d?

i read tutorials and searched but nothing works. could someone tell me how make my character jump, please! Thanks!

Script:

var jumpSpeed = 8.0;

var gravity = 20.0;

private var moveDirection = Vector3.zero;

function FixedUpdate() {

var controller : CharacterController = GetComponent(CharacterController);

if (controller.isGrounded) { // We are grounded, so recalculate

// move direction directly from axes

moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,

Input.GetAxis("Vertical"));

moveDirection = transform.TransformDirection(moveDirection);

moveDirection *= speed;

if (Input.GetButton ("Jump")) { moveDirection.y = jumpSpeed; } }

// Apply gravity moveDirection.y -= gravity * Time.deltaTime;

// Move the controller controller.Move(moveDirection * Time.deltaTime);

}

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
3

Answer by Roux69 · Aug 20, 2010 at 06:14 PM

Your question lacks detail. Right now there is nothing to do because I don't know how your script is made. Specificity is your friend, even more if you show that you're working hard and not waiting for someone to hand to you a ready to work code.

The 2D tutorial works. http://unity3d.com/support/resources/tutorials/2d-gameplay-tutorial

What I suggest is to open the tutorial's demo project and look at the character controller script. See how the jumping works(variables and functions) and try to add it to your own script. Once you've done that, if it still doesn't work, then show us a little of your script and enough detail so that we can help you find what is missing.

if you have a hard time understanding this, look for beginners's tutorials for scripting. They will greatly help, as well as the unity scripting reference.

I too am new to Unity and the first thing I do is to read all that I can see and find relevant. Look through the questions, there are surely a few talking about jumping. And also, it would help to look at how the questions are formulated. There are some questions that will never get an answer because of what I said above.

Good Luck

Comment
Add comment · Show 4 · 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 john 2 · Aug 20, 2010 at 06:28 PM 0
Share

I READ TUTORIALS as I SAID IN $$anonymous$$Y QUESTION BEFORE BUT IT JUST DOESN'T WOR$$anonymous$$. I ADDED $$anonymous$$Y SCRIPT!!!!!!!!

avatar image Roux69 · Aug 20, 2010 at 06:37 PM 0
Share

First: please do not write in caps, it's very irritating. Second, I'm not home at the moment, I'll look into it tonight.

avatar image john 2 · Aug 20, 2010 at 10:02 PM 0
Share

Whatever. i fixed it myself.

avatar image hoy_smallfry · Feb 24, 2013 at 11:31 PM 1
Share

Close your question then.

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

2 People are following this question.

avatar image avatar image

Related Questions

Adding a jump feature help? 2 Answers

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Help with my double jump script 1 Answer

Unity3d Javascript Reference Script Variable 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