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 Ev · Oct 21, 2013 at 08:53 PM · collisionphysicsmaterials

How to restrict for a player movement? Player can go thru the wall.

I have player with next properties:

alt text

Player move code fragment:

 if (isMoveLeft)
         {
             var angle = transform.eulerAngles.z+this.turnSpeed ;
             float yAngle = Mathf.LerpAngle(transform.eulerAngles.z, angle, this.rigidbody.velocity.magnitude * Time.deltaTime );
              
             var rotation = Quaternion.Euler( 0, transform.eulerAngles.y,yAngle );
             rigidbody.MoveRotation( rotation);
             
         }
 
         this.rigidbody.velocity = this.transform.up * flyingSpeed* Time.deltaTime; 


And I have 'wall' (With box collider and physic material)

'bounciness' 1,

'static friction' 100

I cannot go thru the wall instantly - collider is working! But if I will move in that direction for a few seconds player will go thru.

What i am doing wrong?

I want my wall to stops player and that's it.

Something like this doesnot helps:

     void OnCollisionEnter(Collision collision) {
    flyingSpeed=0;
 }
prop.png (19.9 kB)
Comment
Add comment · Show 4
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 darthbator · Oct 21, 2013 at 08:58 PM 0
Share

Are you sure that behavior is firing at all and setting the speed back to 0?

avatar image Ev · Oct 22, 2013 at 08:04 AM 0
Share

@darthbator. Yes i check this in debug mode.

avatar image ahbern · Oct 22, 2013 at 09:44 AM 0
Share

Did the wall gameobject give way or move upon collision?

avatar image Ev · Oct 22, 2013 at 03:11 PM 0
Share

@agoahbern at the beginning player will stuck and then can move forward.

1 Reply

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

Answer by findus_l · Oct 22, 2013 at 10:34 AM

I think the player has to be a trigger so OnCollisionEnter is called.

But you should not need this method. I am not sure but i think if you would make the player move using physical forces the colliders would react and he would be stopped by the wall. Without the callback beeing called or used.

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 sdgd · Oct 22, 2013 at 04:24 PM 1
Share

no OnCollisionEnter isn't called if one is trigger as it passes right through him

OnColisionEnter is called when both are colliders

OnTriggerEnter is Called when 1 is trigger and other is collider and not both triggers

Character controller works fine for not going through things with Controller.move iirc

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

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

Related Questions

How to get Satisfying Collision Physics 1 Answer

Punching a crate 0 Answers

Imported 3D models collisions 1 Answer

FPS Tutorial: Why do my grenades go through the walls? 3 Answers

Exported Scene in .swf loses 2D colliders ? 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