I have this following code in a FixedUpdate() method with a Input.GetMouseButton(0) condition:
public void playerAttack()
{
RaycastHit hit;
if (Physics.Raycast(player.transform.position, player.transform.forward, out hit, range)) //range = 7f
{
if (hit.rigidbody != null && hit.transform.tag == "Enemy")
{
Vector3 dir = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z - 100f);
hit.transform.GetComponent<Rigidbody>().AddForce(dir * weaponPush * Time.deltaTime); //weaponPush = 1f
}
}
}
The enemy object has rigidbody on it and isKinematic is not selected. It still doesn't move when I am almost in front of it and click the left mouse button.
if? - FCin