How can I create movement like a bull? (Enemy run towards player)
So I have an enemy in my game that I want to function like a bull. I want him to find the position of your character, wait a moment and then charge. In this scenario I'm not sure if it's better to just find the original position and go that route strictly, or to have it update slightly to fix the angle as it moves towards the player. I have a slight understanding of how to do that but i'm not sure how to go about it completely. I had something along the lines of this.
GameObject player;
Vector3 playerPos;
public float speed = 12f;
void Start()
{
player = GameObject.Find("Player");
}
void Ram()
{
playerPos = new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z);
transform.position = Vector3.MoveTowards(transform.position, playerPos, speed * Time.deltaTime);
}
And that's all I could really think of. Ideally I want him to face the player then charge. I could figure out the coroutine parts, but I just need somewhere to get started.
If it matters I'm in a 2D setting.
I don't really touch on 2D but what about adding a Rigidbody2D and applying force in the forward direction to move the bull, that would add momentum much like a real bull charging.
Your answer
Follow this Question
Related Questions
Get angle between a position and facing direction 0 Answers
Change camera origin point to top left? 2 Answers
Random position, overlap problem. 1 Answer
Help with Unity Networking and teleporting player 0 Answers
If two Vector2 are same 1 Answer