Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed (Author was flagged for spam)

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
Why is my rigidbody player sticks on a wall whenever it touches?
Post Flair (click to view more posts with a particular flair)
Post Body

Hello, I'm a beginner on the unity platform and I've made a simple script movement that jumps and walks perfectly, therefore, when it touches a wall, it sticks to it, and not falling down. How can I fix this?

Video:

https://reddit.com/link/110p1xr/video/h0fg72ltetha1/player

Code:

using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
    public float _speed;
    public float _jumpForce;
    private Rigidbody _rig;
    private Vector2 _input;
    private Vector3 _movementVector;
    private void Start()
    {
        _rig = GetComponent<Rigidbody>();
    }
    private void Update()
    {
        _input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        if (Input.GetButtonDown("Jump") && IsGrounded())
        {
            _rig.AddForce(Vector3.up * _jumpForce, ForceMode.Impulse);
        }
    }
    private void FixedUpdate()
    {
        //Keep the movement vector aligned with the player rotation
        _movementVector = _input.x * transform.right * _speed   _input.y * transform.forward * _speed;
        //Apply the movement vector to the rigidbody without effecting gravity
        _rig.velocity = new Vector3(_movementVector.x, _rig.velocity.y, _movementVector.z);
    }
    private bool IsGrounded()
    {
        if (Physics.Raycast(transform.position, Vector3.down, 1.75f))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

Pictures:

https://preview.redd.it/axgbxpl9ftha1.png?width=545&format=png&auto=webp&s=c6464a8ba11b040780b96c593d2c83754abde671

Author
Account Strength
0%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
59,315
Link Karma
44,496
Comment Karma
13,279
Profile updated: 8 months ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago