Player starts moving in one direction nonstop after colliding with any other object

My current issue is that when my player capsule collides with any other object that has a collider it starts to move nonstop in the opposite direction of the collision.

Player Components:

Components of other colliders:

Player Controller Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

    //Public Variables

    public Rigidbody myRigidBody;
    public Collider myCollider;
    public float playerSpeed = 25;
    public float playerRotationSpeed;

    //public LayerMask whatIsGround;
    //public bool isGrounded;

    //Private Variables

    private float hAxis;
    private float vAxis;

    private Camera mainCamera;

    private void Start()

        myRigidBody = GetComponent<Rigidbody>();
        myRigidBody.constraints = RigidbodyConstraints.FreezeRotationX;
        myCollider = GetComponent<Collider>();
        //whatIsGround = 1 << 9;
        mainCamera = Camera.main;


    private void Update()

        hAxis = Input.GetAxisRaw("Horizontal");
        vAxis = Input.GetAxisRaw("Vertical");



    private void FixedUpdate()

        Vector3 moveInput = new Vector3(hAxis, 0, vAxis).normalized;
        myRigidBody.MovePosition(transform.position + moveInput * playerSpeed * Time.deltaTime);


    //private void GroundCheck()

    //    Ray groundCheck = new Ray(transform.position, Vector3.down);
    //    if (Physics.Raycast(groundCheck, 1.71f, whatIsGround, QueryTriggerInteraction.Ignore))
    //    {

    //        isGrounded = true;

    //    }
    //    else
    //    {

    //        isGrounded = false;

    //    }


    private void LookAtMouse()

        Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up,;
        float rayDistance;

        if (groundPlane.Raycast(cameraRay, out rayDistance))

            Vector3 pointToLookAt = cameraRay.GetPoint(rayDistance);
            transform.LookAt(new Vector3(pointToLookAt.x, transform.position.y, pointToLookAt.z));
            //Debug.DrawLine(cameraRay.origin, pointToLookAt,;




Link to video with example:

Video Password: Unity

Without all the details relative to the issue I can’t entirely say what it is but unless you intend on having it move a tad bit after letting go of the buttons (like a velocity system or something?) then I suggest you try only running the code in FixedUpdate() and others involving movement to only run when a movement key is pressed, since in your video I only ever spotted it when you weren’t pressing any buttons.

I may be able to use the current info to solve it after closer inspection but it will take time. Try my suggestion and tell me what happens.

I have the same problem. Looks like it’s a bug.

A workaround that has worked well for me is to increase the Radius of the Sphere Collider of the Player just up to the point till it encompasses most of the gun (you can leave the tip of the muzzle out and instantiate bullets from there). The obstacle then collides with the bigger Sphere Collider and the Player stays in place however you collide it.

This will however, make your player easier to hit if shot at.