Great course so far by the way! I checked that they have the Force Receiver correctly set up. No matter what I put in the knockback value for attacks on the player, the enemy won’t get force applied. Player does get knocked back when Enemy attacks. Not sure what I am doing wrong.
Force Receiver script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class ForceReceiver : MonoBehaviour
{
[SerializeField] private CharacterController controller;
[SerializeField] private NavMeshAgent agent;
[SerializeField] private float drag;
private float verticalVelocity;
private Vector3 impact;
private Vector3 dampingVelocity;
public Vector3 Movement => impact + Vector3.up * verticalVelocity;
private void Update(){
if(controller.isGrounded && verticalVelocity<0f){
verticalVelocity = Physics.gravity.y * Time.deltaTime;
}else{
verticalVelocity +=Physics.gravity.y * Time.deltaTime;
}
impact = Vector3.SmoothDamp(impact,Vector3.zero, ref dampingVelocity, drag);
if(agent != null){
if (impact == Vector3.zero){
agent.enabled = true;
}
}
}
public void AddForce(Vector3 force){
impact += force;
if(agent != null){
agent.enabled = false;
}
}
}