So I’ve made my own player controller with the Character Controller component, also I’m using the Rigidbody as well on it to simulate gravity and be able to interact with other rigidbodys. But, when I try to move my crate by walking in to it with the player it wont budge.
Player Movement Script:
```csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float movementSpeed = 2f;
public float jumpForce = 15f;
float moveFB;
float moveLR;
float verticalVelocity;
CharacterController player;
Rigidbody rgbd;
void Start()
{
player = GetComponent<CharacterController>();
rgbd = GetComponent<Rigidbody>();
}
void Update()
{
if(Input.GetButtonDown("Jump"))
Jump();
moveFB = Input.GetAxis("Vertical") * movementSpeed;
moveLR = Input.GetAxis("Horizontal") * movementSpeed;
Vector3 movement = new Vector3(moveLR * Time.deltaTime, rgbd.velocity.y, moveFB * Time.deltaTime);
movement = transform.rotation * movement;
player.Move(movement);
}
void FixedUpdate()
{
verticalVelocity += Physics.gravity.y * 0.05f;
}
void Jump()
{
verticalVelocity = 0f;
verticalVelocity += jumpForce;
}
}**
```
Components attached to the player:
- Character Controller
- Rigidbody
- PlayerController
- MouseLook
Components attached to the crate:
- Cube mesh
- Box Collider
- Mesh Renderer
- Rigidbody
What am I doing wrong?