I have a Zombie Model, where i have a Rigidbody attached and that Moves Towards me and Attacks me.
But it rotates around the frozen X axis and even if i set it in the script with every possible answer, it doesnt work
public void FixedUpdate()
{
transform.Rotate(0, transform.rotation.y, transform.rotation.z, Space.World);
}
// Update is called once per frame
void Update()
{
DistanceToPlayer = Vector3.Distance(transform.position,player.position);
if(DistanceToPlayer < safeDistance)
{
transform.LookAt(player.position);
transform.Translate(new Vector3(0, 0, 0));
if (canAttack == false) return;
ZombieAnimator.Play("Attack");
Invoke("Attack", 2.0f);
canAttack = false;
if(Health.playerarmor > 0)
{
Health.playerarmor -= 10;
}
else
{
Health.playerHealth -= 15;
}
}
if(DistanceToPlayer > safeDistance)
{
transform.position = Vector3.MoveTowards(transform.position, player.position, movementspeed * Time.deltaTime);
transform.LookAt(player.position);
ZombieAnimator.Play("Walk");
}
}
void Attack()
{
canAttack = true;
}