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 oliver-jones · Sep 24, 2013 at 10:24 PM · collisionmovementphysicscollider

Collision Issue - Walk Through Object

Hello,

I've been working on a top down shooter game for sometime now, and I've always had this problem where I can walk through colliders by 'rubbing' against them, side to side.

So initially, if I run into a wall (for example), yes, it will stop me. But as I said, moving the character side to side of the wall, will eventually pop me through to the other side.

I don't know what the issue here is. Let me explain what I have:

Player:

  • Rigidbody (Is Kinematic, Frozen all constrains, Interpolate, Continuous detection)

  • Character Controller

  • Capsule Collider (Slightly larger radius than Character Controller)

Collider Object

  • Box Collider

Player Scripts (Movement):

Basically, the character will always face towards the position of the mouse. By pressing W will always move it towards the MOUSE.

 function Update(){
         var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
         var playerRotateSpeed = 10;
     
         var hitdist = 0.0;
         var targetPoint = ray.GetPoint(hitdist);
     
         var lookPos = targetPoint - transform.position;
         lookPos.y = 0;
     
         if(canMove){
             var targetRotation = Quaternion.LookRotation(lookPos);    
             transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, playerRotateSpeed * Time.deltaTime);
     
             var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
     

         directionVector = transform.rotation * directionVector * walkingSpeed; 
         motor.inputMoveDirection = directionVector;
     }
     transform.position.y = 2.76011;
 
 }


Now I have a feeling that this script is actually causing the issue? The character will still continue to walk even if there is a collider in its way. Right? Or is it something else?

FYI - On very small occasions, the character will just walk straight through a collider without any struggle, as if it wasn't even there.

Thanks.

Comment
Add comment · Show 2
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 svenskefan · Sep 25, 2013 at 12:00 AM 0
Share

You are effectively mixing movement thru the physics engine with directly setting transform values.

"transform.position.y = 2.76011;"

I assume this is what is causing you problems. If you need to restrict the y position, you could place a configurable joint on the character and tie it to the world pos of y=2.76011.

avatar image oliver-jones · Sep 25, 2013 at 08:59 AM 0
Share

Would it be better moving my rigidbody, rather than the transform then?

0 Replies

· Add your reply
  • Sort: 

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

16 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

Related Questions

How having correct bounce on a rotating pinwheel(it's more complicated)? 0 Answers

Stopping my player from moving when hitting a wall. 5 Answers

Camera gets flung off of the map when the player collides with certain objects. 0 Answers

Punching a crate 0 Answers

Tossing an object with the correct force at any distance from another so that it collides with the other 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