Stopping all player interactions with OnCollisionEnter?

Hi

Basically I want my object that is controlled by getKeyUp to ignore key presses once it hits another object while still maintaining all physics attributes ie the player can no longer control said object but the object can move based off of physics from the environment.

As many people suggest making it kinematic or locking all movement but thats not how I want my game to work.

Any Ideas?

Thanks

Hi, why not triggering a boolean on collision enter and checking if is this boolean is true or false where you did the gameplay code ?

Something like :

bool canMove;

void OnCollisionEnter() {
    canMove = false;
}

void Update() {

    if(canMove) {
        if(someKeyPressed) {
                //move
        }
    }
}

Yes that works, I ended up doing an OnCollisionEnter to set a variable value to 1 and i used an if else statement to check if that value was 1 or not.

if (ObjectHit == 1)
        {
            //do nothing
        }

        else
        {
            if (Input.GetKeyUp(KeyCode.RightArrow))
            {
                transform.position += new Vector3(2, 0, 0);
            }

            if (Input.GetKeyUp(KeyCode.LeftArrow))
            {
                transform.position += new Vector3(-2, 0, 0);
            }
        }


    }

    private void OnCollisionEnter(Collision collision)
    {
        ObjectHit = 1;
    }