Enemy path Error

The problem i am having is that when there is a new enemy spawning my enemy in front stops for a moment. because of this my enemy will walk of the track and the turret will shoot to nothing. Any idea about how i can fix this ?? could it be something with the yield functions??

Hi,

Welcome to our community! :slight_smile:

Why does the enemy spawn? Is that supposed to happen? Does it spawn at the expected position? Are there any error messages in your console?

Hi nina,

The enemy spawns automaticaly becaus of the Enemyspawn script.
No the enemy should not side track or freeze yes the enemy’s should spawn.
They spawn at the location where they should spawn.
I have no error messages what makes it harder to fix this.

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

The enemies should not be connected with the EnemySpawner object, thus the enemy which stops for a moment when a new enemy gets spawned should not do that because of the EnemySpawner.

The game window is just a preview which is known for being a bit laggy. Try to build your game to see if the issue you noticed is also an issue in your build. If the enemies move as expected in the build, it might be that it is just an unsolveable problem in the Unity Engine, not in your project.

And if the issue also happens in the build, log relevant values into your console such as Time.frameCount along with the enemy position and/or a message when a specific method got called. This way, you’ll figure out what is going on during runtime. As you said, without any error message, debugging is fairly challenging but logging values into your console is always a good start.

Then i will have to work with logging.

I compared the code indeed with the lecture but couldn’t find any difference.
I also build the game to test the lagging but it still happens.
So i will have to logg the values and hope i can find the error.

Do you happen to use a laptop? If so, make sure the power chord is plugged in.

And something came to my mind: Where exactly does the enemy in front stop? At a waypoint? If so, that issue is caused by Rick’s code.

No i am using a desktop
If i am right every block in the game is a way-point?? so yes it stops at a waypoint

I made the serialized field in enemy movement to see what the path is of the enemy but the size of the path that i get is 0. so there is probably something wrong with that.

Exposing the path is a good idea, and it should have worked. Could you share the relevant code as formatted text?

This topic was automatically closed after 73 minutes. New replies are no longer allowed.

Privacy & Terms