This is what I have it's a script for a enemy to follow the player in 2d
I keep getting these errors:
Assets\Scripts\EnemyFollow.cs(32,33): error CS1002: ; expected
Assets\Scripts\EnemyFollow.cs(32,94): error CS1002: ; expected
Assets\Scripts\EnemyFollow.cs(32,94): error CS1513: } expected
I am sorry if its a easy fix I am fairly new to unity and coding in general any help would be appreciated
Thanks, your friend Stratc
public Transform player;
public float moveSpeed = 5f;
private Rigidbody2D rb;
private Vector2 movement;
void Start()
{
rb = this.GetComponet();
}
void Update()
{
Vector3 direction = player.position - transform.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
rb.rotation =angle;
direction.Normalize();
movement = direction;
}
private void FixedUpdate()
{
moveCharacter(movement);
}
void moveCharacter(Vector2 direction)
{
rb.MovePosition(Vector2)transform.position + (direction * moveSpeed * Time.deltaTime));
}
↧