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 NinjaRubberBand · Nov 25, 2013 at 12:04 PM · movementphysicsjump

My ball stops bounching at certain hight

I have a movement script, and a 2d physic material attached to my sprite ball. The material does so it constantly bounches without stopping. But the problem is, it only can jump to a certain point on the y axis. for example when i jump on a platform which is higher than the previous it doesen't jump that high anymore only to that point on the y axis. How can i fix this?

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 diegzumillo · Nov 25, 2013 at 12:09 PM

If I understand what you are describing, this is the intended behavior of a physics object. Jumping higher would be like creating energy from thin air :)

My suggestion is: don't use a bouncy material! in fact, use a material that completes eliminates bouncing. Then you add force at each impact directly from script. Each time the ball touches the ground, you apply an F amount of force upwards. I think this would get you the effect you want.

Comment
Add comment · Show 12 · 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 NinjaRubberBand · Nov 25, 2013 at 12:20 PM 0
Share

Okay so im new to scripting and started 10 days ago. But i managed to make a movement script in a previous project. I took the jump from that script and made some few modifications. But the ball seems to ''lag'' alot.

transform.Translate(Vector3.up jumpSpeed Time.deltaTime);

Physics.gravity = Vector3(0, -30, 0);

}

}

avatar image diegzumillo · Nov 25, 2013 at 12:23 PM 1
Share

Oh, that's because you're using translate() on a rigidbody. You should avoid that. Use Rigidbody.AddForce( direction *intensity ) (look at the documentation for the correct syntax)

avatar image NinjaRubberBand · Nov 25, 2013 at 01:20 PM 0
Share

I don't know if this is correct:

function FixedUpdate () {

rigidbody.AddForce (0, 50, 0); } Also, its a 2d rigidbody attached to my ball, so it says: $$anonymous$$issingComponentException: There is no 'Rigidbody' attached to the "Ball"
avatar image diegzumillo · Nov 25, 2013 at 02:07 PM 0
Share

From what I gathered in your question, your ball has a rigidbody2d attached, so you should use Rigidbody2D.AddForce. I know it may sound a little confusing but things will become clear with time and practice. physics and physics2d are pretty much equivalent but are different components.

Now in order for you to apply force only when it impacts the floor, I would suggest also looking up the OnCollisionEnter2D function. Here's a link: http://docs.unity3d.com/Documentation/ScriptReference/Collider2D.OnCollisionEnter2D.html

avatar image NinjaRubberBand · Nov 25, 2013 at 02:38 PM 0
Share

Yeah it does sound confusing :-)! But im learning, not fast but im learning! So i combined the scripts to this:

 function OnCollisionEnter2D(coll: Collision2D) {
 if (coll.gameObject.tag == "Ground")
     rigidbody2D.AddForce(Vector3.up * 10);

}

But as you probably can see it does not work ..

Show more comments

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

17 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

Related Questions

Sphere get stuck in floor and fails to jump? 1 Answer

How can I make a physics object jump a given height on collision regardless of current velocity? 1 Answer

Interpolate problem? Jump isn't smooth... 1 Answer

Hinge Joint Segments rotating offscreen 0 Answers

Keep Horizontal Momentum after Jump 2 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