• 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 /
  • Help Room /
avatar image
Question by Aldanwildforged · May 14, 2017 at 07:18 PM · rigidbodyfps controllermesh colliderstandard-assets

RigidBody FPS Controller(standard assets) gets stuck on mesh colliders

I imported a mesh I had made from Blender into Unity (.dae format). The mesh had a ramp going up to a second floor, the ramp is at a 45deg angle. When the RigidBody FPS Controller from the standard assets tried to walk up the ramp it slow down to a crawl and would occasionally slide back down. It would also get stuck in the corner of the mesh especially after it slid down the ramp. The other SA Fps controller did not have any problems, But I needed it to react to physics for the game so I'm unable to use it. I don't believe it is sliding/ slowing down due to friction, or a lack there of because I tried using a variety of physic martials on both the controller and the mesh to no effect. The problem could not be replicated using the other collider types. I've seen similar problems from other people but no solutions were posted.

Comment
phyatt
Mobazy

People who like this

2 Show 1
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 Coleclaw199 · May 16, 2017 at 08:28 PM 0
Share

By the way, I don't know the glitch in your project, sorry.

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Viriato · Jun 05, 2017 at 08:26 PM

Just set the "Shell Offset" variable to 0.1 in the "Advanced Settings" of the "Rigidbody First Person Controller" script.

Comment
gohome
master_rigel
phyatt
Mobazy
mightWizard

People who like this

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

Answer by Coleclaw199 · May 16, 2017 at 08:28 PM

You should probably not use the built in FPS controllers, so here is a simple movement script and a mouse look script. By the way, the player needs a character controller, and these scripts are aren't tested.

Movement

 using UnityEngine;
 
 public class Player_Movement : MonoBehaviour 
 {
     private float jumpSpeed = 8.0F;
     private float gravity = 20.0F;
     private float speed = 10.0F;
 
     private Vector3 moveDirection = Vector3.zero;
 
     private CharacterController controller;
 
     void Start()
     {
         controller = GetComponent<CharacterController>();
     }
 
     void Update() 
     {
         CheckForWalk();
         CheckForSprint();
     }
         
     void CheckForWalk()
     {
         // Is the controller on the ground?
         if(controller.isGrounded) 
         {
             // Feed moveDirection with input.
             moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
             moveDirection = transform.TransformDirection(moveDirection);
 
             // Multiply it by speed.
             moveDirection *= speed;
 
             // Jumping.
             if(Input.GetButton("Jump")) 
             {
                 moveDirection.y = jumpSpeed;
             }
         }
 
         // Applying gravity to the controller.
         moveDirection.y -= gravity * Time.deltaTime;
 
         // Making the character move.
         controller.Move(moveDirection * Time.deltaTime);
     }
 
     void CheckForSprint()
     {
         if(controller.isGrounded && Input.GetKey(KeyCode.LeftShift)) 
         {
             speed = 11.0F;
 
             // Feed moveDirection with input.
             moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
             moveDirection = transform.TransformDirection (moveDirection);
 
             // Multiply it by speed.
             moveDirection *= speed;
 
             // Jumping.
             if(Input.GetKey(KeyCode.LeftShift)) 
             {
                 moveDirection.y = jumpSpeed;
             }
         } 
 
         else if(!Input.GetKey(KeyCode.LeftShift))
         {
             speed = 10.0F;
         }
     }
 }
Comment
axoona

People who like this

1 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 Coleclaw199 · May 16, 2017 at 08:33 PM 0
Share

Here is the mouse look.(Reminder: these are not tested.)

 using UnityEngine;
 
 [AddComponentMenu("Camera-Control/Smooth Mouse Look")]
 
 public class Player_MouseLook : MonoBehaviour 
 {
     public Vector2 clampInDegrees = new Vector2(360, 180);
     public Vector2 sensitivity = new Vector2(2, 2);
     public Vector2 smoothing = new Vector2(3, 3);
     public Vector2 targetCharacterDirection;
     public Vector2 targetDirection;
     private Vector2 _mouseAbsolute;
     private Vector2 _smoothMouse;
 
     public GameObject characterBody;
 
     public bool lockCursor;
 
     void Start()
     {
         targetDirection = transform.localRotation.eulerAngles;
 
         if(characterBody) 
         {
             targetCharacterDirection = characterBody.transform.localRotation.eulerAngles;
         }
     }
 
     void Update()
     {
         Cursor.lockState = CursorLockMode.Locked;
 
         var targetOrientation = Quaternion.Euler(targetDirection);
         var targetCharacterOrientation = Quaternion.Euler(targetCharacterDirection);
 
         var mouseDelta = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
 
         // Scale input against the sensitivity setting and multiply that against the smoothing value.
         mouseDelta = Vector2.Scale(mouseDelta, new Vector2(sensitivity.x * smoothing.x, sensitivity.y * smoothing.y));
 
         _smoothMouse.x = Mathf.Lerp(_smoothMouse.x, mouseDelta.x, 1f / smoothing.x);
         _smoothMouse.y = Mathf.Lerp(_smoothMouse.y, mouseDelta.y, 1f / smoothing.y);
 
         _mouseAbsolute += _smoothMouse;
 
         if(clampInDegrees.x < 360) 
         {
             _mouseAbsolute.x = Mathf.Clamp (_mouseAbsolute.x, -clampInDegrees.x * 0.5f, clampInDegrees.x * 0.5f);
         }
 
         var xRotation = Quaternion.AngleAxis(-_mouseAbsolute.y, targetOrientation * Vector3.right);
 
         transform.localRotation = xRotation;
 
         if(clampInDegrees.y < 360) 
         {
             _mouseAbsolute.y = Mathf.Clamp (_mouseAbsolute.y, -clampInDegrees.y * 0.5f, clampInDegrees.y * 0.5f);
         }
 
         transform.localRotation *= targetOrientation;
 
         if(characterBody)
         {
             var yRotation = Quaternion.AngleAxis(_mouseAbsolute.x, characterBody.transform.up);
             characterBody.transform.localRotation = yRotation;
             characterBody.transform.localRotation *= targetCharacterOrientation;
         }
 
         else
         {
             var yRotation = Quaternion.AngleAxis(_mouseAbsolute.x, transform.InverseTransformDirection(Vector3.up));
             transform.localRotation *= yRotation;
         }
     }
 }
avatar image

Answer by master_rigel · Jul 07, 2018 at 02:23 PM

Just set the "Shell Offset" variable to 0.01 in the "Advanced Settings" of the "Rigidbody First Person Controller" script.

Setting values greater than this, may create a gap between the controller and the colliding object.

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

120 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 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 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 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 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 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 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

Mesh Collider Misplaced 0 Answers

How do I make it so the rigibody on the parent uses the mesh collider on the children ? 0 Answers

Parented Object moves weirdly in FPS Standard Asset Camera 0 Answers

Input.GetAxis not going forward 0 Answers

im using unity 2018.4 standard assets and i added arms to a FPSController and the arms dont have collision 0 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