Question by
AlexTheScripter · Sep 03, 2019 at 04:22 AM ·
movementrigidbodyrigidbody-collision
Rigidbody FPS controller getting stuck on walls.
I'm trying to make a Wolfenstein3D style movement controller, it works fine until I rub against a wall, this for some reason brings the player to a grinding halt
public class playerMovement : MonoBehaviour
{
private float Starthealth = 100f;
public float health;
public float moveSpeed = 3.0f;
public float rotationSpeed = 5.0f;
void FixedUpdate()
{
float rotateTank = Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime;
float moveTank = Input.GetAxis("Vertical");
GetComponent<Rigidbody>().velocity = transform.forward * moveSpeed * moveTank;
GetComponent<Rigidbody>().freezeRotation = true;
transform.Rotate(0, Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime, 0);
}
}
Comment
Your answer
Follow this Question
Related Questions
Stopping Moving Objects? 0 Answers
Player stuck when jumping into a wall 0 Answers
Determine the direction an object is actually moving? 0 Answers
Player movement help! 0 Answers
Error CS0201 when trying to change RigidbodyConstraints 1 Answer