How do i push an object? i use character controller
The objects you want to push should have rigidbody and collider components. In a component attached to your player with the CharacterController, have something like
void OnControllerColliderHit(ControllerColliderHit hit)
{
Rigidbody hitRigidbody = hit.collider.attachedRigidbody;
if (hitRigidbody != null && hitRigidbody.isKinematic == false)
{
hitRigidbody.AddForceAtPosition(hit.moveDirection * (characterController.velocity.magnitude / hitRigidbody.mass), hit.point, ForceMode.VelocityChange);
}
}