25 lines
608 B
C#
25 lines
608 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerKick : MonoBehaviour
|
|
{
|
|
[SerializeField] private float kickForce = 8f;
|
|
|
|
private void OnControllerColliderHit(ControllerColliderHit hit)
|
|
{
|
|
if (hit.collider.CompareTag("Ball"))
|
|
{
|
|
Rigidbody rb = hit.collider.GetComponent<Rigidbody>();
|
|
|
|
if (rb != null)
|
|
{
|
|
Vector3 direction = hit.moveDirection;
|
|
direction.y = 0.3f;
|
|
|
|
rb.AddForce(direction * kickForce, ForceMode.Impulse);
|
|
}
|
|
}
|
|
}
|
|
}
|