Answer the question
In order to leave comments, you need to log in
How to change the speed of the enemy through the script?
Hello!
I wrote a script for the enemy in which there is a speed parameter. I would like that when the Player entered the zone of action of the trigger, the speed parameter changed, for this I wrote the Script, but did not understand how to change the speed parameter.
Help me please!
The script itself:
void Start()
{
GetComponent();
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.name.Equals("Player"))
{
Change enemy's float Speed parameter.
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question