Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Joe 24 · Jun 20, 2011 at 02:06 PM · rotationmovementcollidercharactercontrollerpath

Character Controller slides sideways when it hits objects are angles different from 90 degrees

Hi there I'm new to Unity and new to UnityAnswers. I have a programming background so I'm doing all my scripting in C#. I have an issue with my character controller. The Script for the movement I have basically makes my character move on a fixed path around a circumference with center (0,0,0). That works fine, except when there is an obstacle in the way, where I want the character to stop when it collides with it. Lets say my character hits a wall in the path, instead of stopping, it's sliding sideways through the wall. It only stops at the wall if the angle between the character and the wall is 90. This has nothing to do with the slope. The character is NOT climbing the wall, is walking side ways, to the left or right depending on the angle.

What I'm doing to move my character is add some speed to the forward vector of the character and then rotate it according to the angle in the circumference, then do the same next update.

Could anybody help me figure out what am I missing? Thanks Joe

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 Bunny83 · Jun 20, 2011 at 04:34 PM

That sounds to me like the normal collision response. If you walk up to a wall in an narrow angle you don't want to stop the motion when you touch the wall. The speed gets projected along the wall. If you hit the wall at a right angle the projected speed will be "0" of course.

If you want to stop the motion you should stop moving the character forward when you collided with a wall.

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 Joe 24 · Jun 20, 2011 at 05:11 PM 0
Share

Hi, thanks for the response. I noticed in another sample that's the expected behavior, I was looking for a way of limiting this projection without having to check for a collider. I'm trying to $$anonymous$$imize the checks I have in my physics controller since I intend this to run on iPhone 3G and so far the performance is not so good. I thought that a possible solution could be on collision to update the character rotation against the collider's normal. That however could misbehave when the character get's trapped between two walls or similar situations. What do you think?

avatar image Bunny83 · Jun 20, 2011 at 05:25 PM 0
Share

Well, the collision will happen anyway, so your solution sounds quite similar :D. You could of course rotate the character that it looks along the negative hit normal, but if you continue moving forward you will collide every frame and therefore OnControllerColliderHit will be executed every frame.

I don't know your setup. Does the objects you collide with are moving? It should be possible to place a trigger in front of your objects (maybe it works as well when you add a trigger to your character). If you get the OnTriggerEnter event you should stop moving forward and when OnTriggerExit occurs you can continue moving.

avatar image Joe 24 · Jun 20, 2011 at 05:31 PM 0
Share

That actually sounds better. I'll try that later today and I'll let you know how it goes. Thanks!

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

2 People are following this question.

avatar image avatar image

Related Questions

Click to Move rotation + collider issue 0 Answers

OnCollisionEnter 1 Answer

Player model rotates forward with camera 0 Answers

How to change the angle my character falls at 1 Answer

Why can't I properly 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