Question by
mniebieski · Jul 08, 2021 at 05:11 PM ·
beginners
Does speed of PlayerCharacter affect the colliders?
I have created a simple PlayerController, code below.
The PlayerCharacter has a collider and a rigidbody. So do other objects in the game. When the speed is lower than 10, the colliders work. If the speed is higher, the player just goes right through all colliders.
Why does this happen?
CODE:
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 20.0f;
public float turnSpeed = 2000.0f;
public float horizontalInput;
public float verticalInput;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
verticalInput = Input.GetAxis("Vertical");
transform.Translate(Vector3.forward * Time.deltaTime * speed * verticalInput);
// transform.Translate(Vector3.right * Time.deltaTime * turnSpeed * horizontalInput);
transform.Rotate(0, Time.deltaTime * turnSpeed * horizontalInput, 0);
}
}
Comment