Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 TheDavil · Apr 13, 2011 at 10:56 AM · physics2d-platformerjump

2.5D Platformer - Jump Question

Noob question for a 2.5d platformer -

Should I use transform.translate for left and right movement, and a physics 'addforce' for upward thrust of jump ?

Currently I calculate a 'moveDirection' using Input.GetAxis("Horizontal") and I add a 'moveDirection.y = jumpHeight;' when jump key is pressed, and then finally apply it all with

controller.Move(moveDirection * Time.deltaTime);

I can upload my entire code if necessary but I think you'll get the idea. It just seems that there are so many ways to move things and I'm having trouble figuring out what's best.

P.S. is it possible to do a comparison on a translate position and a float like this:

if (gameObject.transform.position.y <= jumpMaxFloatVar)

it doesn't seem to work, I can print out gameObject.transform.position.y but my guess is it's not a float ?

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 Proclyon · Apr 13, 2011 at 11:09 AM 1
Share

It's not a noob question. There are no noob questions.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Proclyon · Apr 13, 2011 at 11:06 AM

As I have said before in several answers, the translation concept is often confused for movement. This is a common misconception as movement is the continous flow between two points, the transform property can manipulate time and space and go to places by changing the x,y,z variables. If done over time it looks like movement , but actually the engine will not see this as movement and thus ignore events such as collisions.

You avoid this problem by using a character controller object attached to your "player" object and manipulate that with it's move function which will , as the name implies, move the character, rather then teleport it a lot in very little time.

Physics can be used to literally kick and push something around, but imagine in real life what that would be like? Jumping by applying a kick at the right moment? Sure, easy, and now navigate a maze? Would that be harder? What about slopy mountains with ice patches and wind blowing around? It's going to get really hard really fast making it a not so worthwhile time investment to apply physics to jump in my experience.

So the conclusion I will make for your suggested approach:

Should I use transform.translate for left and right movement, and a physics 'addforce' for upward thrust of jump ?

I would say, No, use character controller options instead and keep in mind that if you change gravity in the game or in the future of the game, you need to have considered that in the design. So jumping with +9.81 all the time could be a problem later if you want to build a low-grav mode such as in the Unreal Tournament Environment.


SideNote: All these answers are actually quite easy to extrapolate from the great naming conventions the unity3D group has given their objects and properties. They don't just call a PLUS a MINUS (which some pesky students may overload to spice up your monday). Character Controller really means, it controls the character. These names should be a big marker for everyone to consider using it for that goal , and avoid sidetracking untill ABSOLUTELY NECESSARY!

Comment
Add comment · Show 3 · 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 FreeTimeDev · Apr 13, 2011 at 01:02 PM 0
Share

Using addforce wouldn't prohibit the use of any sort of gravity effect. It'd be very easy to set up a trigger (a new room) to send a new variable (or, modifier to multiply against the normal jump height) to act as a new jump speed. Then you could have low grav with fans at the top blowing you back down =)

I don't think "it wouldn't work well" is a good response for unity. "so and so may be easier to work with" or "this or that is more efficient" on the other hand are common problems.

avatar image Proclyon · Apr 13, 2011 at 01:11 PM 0
Share

Thanks for contributing an answer to Stack Overflow!

This is a Q&A site, not a discussion forum, so please make sure you answer the question.

Provide details and share your research. Avoid statements based solely on opinion; only make statements you can back up with an appropriate reference, or personal experiences. <-------- Personal experiences. It's not unity3D forum but it'll do

avatar image TheDavil · May 03, 2011 at 03:45 PM 0
Share

Thanks Proclyon ! Sorry about the delay in getting back to you but I did read this as soon as you wrote it and this was very helpful. Although I've been jumping from Unity to 3ds $$anonymous$$ax to Blender a lot lately in my College Course, I'm finally getting to grips with the simple scripting stuff in Unity. Attempting some raycasting today. I'll see how I go. And yes, the function/class na$$anonymous$$g conventions are ace, as well as the script reference, which is also amazing. Thanks for your time.

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

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

2D Platformer with custom physics Object - jumping issue 0 Answers

2d grounded check problem? 3 Answers

Jump Script being extremely "sticky", performance issue? 1 Answer

Help with my double jump script 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