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 xToxicInferno · May 16, 2010 at 12:29 AM · bounce

Creating a bounce effect?

I am creating a game where the player must climb to the top by bouncing on the floating platforms. I wish to have it so when the player hits the platform they will bounce up x units. The code I had:

var bounce : int = 10;

function OnCollisionEnter (other : Collision) { if(other.gameObject.tag == "Bounceable") { transform.position.y = bounce * Time.smoothDeltaTime; } }

does not work correctly. As soon as the player hits the defined object he just appears 10 units above the object, with no smooth jumping effect at all. I also want to be able to control the character on his way up and back down but I do not know how to do this as it just teleports.

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

3 Replies

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

Answer by qJake · May 16, 2010 at 12:35 AM

You want to use something like Rigidbody.AddForce. This will let you "push" the object upwards using a force value you specify. Be sure to change the ForceMode to something like Impulse (basically burst-force), otherwise you won't notice it at all.

You could also set the Rigidbody's velocity manually, specifying a velocity of something like (0, -10, 0) to make it move in an upwardly direction.

Comment
Add comment · Show 1 · 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 xToxicInferno · May 16, 2010 at 12:47 AM 0
Share

Works perfectly, thank you! I changed it so ins$$anonymous$$d of transfor$$anonymous$$g the position in the OnCollisionEnter function i simply had it make a boolean true in the fixedupdate so it would work right.

avatar image
2

Answer by poncho · Dec 21, 2010 at 09:46 PM

the problem about using, adding force or modifying velocity is that only works for the horizontal or vertical collisions, when you try to make it collide with a pline like 45 / or \ there goes a lot of problems cuz there is need for sin and cos equations and some other vector stuff, the unity physics for the bounce can be add in this way

Asset>Create>Physics Material, then to the object change the bounciness to a value more than 0 and drag the new material to the object you want to make it bounce,

the problem with this is that if you lauch an object it will stop in a few bounces cuz there are alot of things as friction, drag, angular drag, mass that stop it

hope it help

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

Answer by condorbox · Apr 25, 2019 at 02:50 PM

You can create a Physics material and change the Bouncing

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

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

1 Person is following this question.

avatar image

Related Questions

Making Pong 1 Answer

Bouncing objects and Energy loss 2 Answers

Bounce with speed 1 Answer

perfect bounce when a bullet hits a wall 1 Answer

I wanna setup something like Kinematic option on sphere but with collision checker. 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