- Home /
Question by
rscoder7 · Sep 05, 2020 at 06:41 AM ·
collisionmovementrigidbodymoveposition
My Character Moves through walls
My character in the game is moving straight through obstacles, I have tried many answers but none work, it has a rigidbody and is meant to automatically move and so is the camera. The joystick is just for rotation, not movement.
comments are answers I've tried already
public Rigidbody rb;
public Joystick joystick;
[SerializeField] float thrust = 100f;
// Start is called before the first frame update
void Start()
{
//for constraints (normal rigidbody constraints aren't working)
Rigidbody rb = GetComponent<Rigidbody>();
rb.centerOfMass = Vector3.zero;
rb.inertiaTensorRotation = Quaternion.identity;
thrust = thrust * Time.deltaTime;
}
// Update is called once per frame
void Update()
{
Camera.main.transform.Translate(Vector3.left * thrust);
//transform.Translate(Vector3.forward * thrust);
//rb.velocity = new Vector3(0, 0, thrust);
//rb.MovePosition(rb.gameObject.transform.forward * thrust);
//rb.AddRelativeForce(Vector3.left * thrust * Time.deltaTime);
}
void FixedUpdate()
{
//rb.MovePosition(rb.gameObject.transform.forward * thrust);
}
Comment
Answer by mbro514 · Sep 05, 2020 at 04:18 PM
My guess is that the Rigidbody is set to kinematic, in which case it would go through walls and other obstacles.
Answer by rscoder7 · Sep 08, 2020 at 07:41 AM
I have put a box collider, I thought adding one would fix the problem too but it didn't work. The rigidbody is not kinematic either @LionelNoronha1 @mbro514