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 gaboumafou · Aug 31, 2010 at 10:46 PM · physicscharactercontrollerjumprebound

"Rebound" effect when the character jump on an ennemy

Hello,

I am a member of a team working on a 2.5D plarformer. We got most of our mechanics working, but for some reason we are completely unable to add a "rebound" effect when the Player Character jump on an ennemy.

Since a Character Controller can't be affected by physics, using the "bouncy" material is out of the question.

How would you script a "rebound" effect for the Character Controller?

We are really new to scripting and game creation, so sorry if the answer is obvious.

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

2 Replies

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

Answer by · Sep 01, 2010 at 02:50 AM

Along the same lines as Will's suggestion, you could try just inverting the Y-axis velocity, or explicitly set it to a value.

The scripting reference for RigidBody.Velocity suggests:

In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour

However, that may not be an issue for you here (depending on style of game, and the gameplay outcomes, etc)

If you want to rebound based on how fast you are falling, you could try something like:

rigidbody.velocity.y = -rigidbody.velocity.y * 0.8;

This would mean that if the player character was moving (down) on the y axis at 10 m/s, they would be instantly set to bounce up at 8 m/s.

If you wanted reliable bounces, you could explicitly set it to a value.

** This may not be the best way, but I don't think using the relativeVelocity is ideal for typical 2.5D platformer behaviour.

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
0

Answer by Will 7 · Sep 01, 2010 at 02:32 AM

Well I am new too, but have you tried finding the velocity of the player and then on collision reversing it into a negative?
on collision{ rigidbody.velocity.y = (collision.relativeVelocity-(collision.relativeVelocity*2)) rigidbody.velocity.x = (collision.relativeVelocity-(collision.relativeVelocity*2)) } No idea if this would work or not but it might be worth a try.

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

No one has followed this question yet.

Related Questions

Control Mid-Air Movement With Character Controller 1 Answer

A more realistic jump using CharacterController -1 Answers

Turning a rigidbody controller into a character controller (almost) 1 Answer

Rigidbody2d not falling once in the air 1 Answer

Can a character controller collide with a trigger? 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