• 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
Question by raddry · Feb 04, 2013 at 07:46 PM · c#collisionmovementbounce

Avoid character bouncing off of obstacles

Hello, I'm currently working on a simple platformer game to learn using Unity (since I'm fairly new to this tool and to its scripting, I'm using C# at the moment).

I made a script for character movement and jumping (I prefer making it myself rather than using anything that comes with the software). However, when the character encounters an obstacle it awkwardly bounces off, I'd like to avoid that, just a simple stop on collision. So I'm wondering how to do it, maybe make a check if there is a collision with anything else than the floor and if so, stop movement?

Comment

People who like this

0 Show 8
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 joeyaaaaa · Feb 04, 2013 at 07:52 PM 0
Share

yep liek you said, check for collision, if contact with tag or name of the collider, stop the player, but that might be the hard part to script, it also may be rigidbody thats making him bounce?

avatar image hoy_smallfry · Feb 04, 2013 at 08:25 PM 0
Share

Can you be more clear about how your character object is set up? Does your character have a kinematic rigid body? Are you using a physics material? Does your character movement script manipulate the Transform, or does it apply forces?

avatar image raddry · Feb 05, 2013 at 03:33 PM 0
Share

My character isn't kinematic, not using physics material (thought about it but doesn't seem to work for that, maybe you can tell me if there's a way), and my movement script manipulate the Transform. I will try to script it but if there's a simpler way, I'm taking.

avatar image Professor Snake · Feb 05, 2013 at 04:14 PM 0
Share

The transform-based movement might place your character object inside one of the objects, and if both your character and the object have non-kinematic rigidbodies with colliders, it can result in the objects bouncing off. I would suggest using some other form of movement if you want actual collisions. (Perhaps character controllers would do the trick)

avatar image raddry · Feb 05, 2013 at 06:57 PM 0
Share

What do you mean by character controllers? Also, the obstacle is kinematic.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by OmarAlhaddad · Feb 11, 2013 at 10:36 AM

You can try using a Character Controller to move your character, add it from Component > Physics > Character Controller

After you add it you can access it by:

 CharacterController controller;
     void Start() {
     controller = GetComponent<CharacterController>();
  
     //..etc
     }
     
     void Update() {
     controller.Move(/*use your motion Vector3 Here*/);
     //..etc
     }

Good luck

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

13 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

Related Questions

Avoid character bouncing off of obstacles 0 Answers

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

Making a bubble level (not a game but work tool) 1 Answer

Sounds triggering too fast 4 Answers

Problem with player movements 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