I just finished a freakishly long enemy behavior script. Everything is working perfectly and the script is fairly easy to read for how long it is! I’m extremely happy with the enemy AI when I test it in play mode, but when I “build and run” the enemy’s speed decreases significantly when it is in it’s agro state. I am not sure what to do and I have read my script over for any errors many times, any ideas? I appreciate any help that is given, thanks!
The slowing happens specifically when I use transform.position = Vector2.MoveTowards(transform.position, player.position, (speed * angerMultiplier) * Time.deltaTime);
, this line is to make the enemy chase the player
At the risk of being shot down for being a Grammar Nazi, watch the spelling on your scripts, they’re case sensitive.
I don’t see it XD is it a problem with my code or just a spelling error? Can you point it out to me?
Can you post the rest of the script? Can’t tell what is going on because I can’t see where those other variables are coming from.
For example, if you were already applying Time.deltaTime to one of the other variables you are using, like your “speed” variable, I’d expect this kind of thing to happen. If that were the case, the higher your frame rate the slower the object would move. Builds typically can achieve higher frame rates than Play Mode because they get compile time optimizations and no longer have the Editor overhead.
I don’t see an obvious spelling or case sensitive issue with the line you posted. If you had one you’d be getting a compile error though.
OH! That makes sense. I am using void “FixedUpdate()” along with multiplying my variables by Time.deltaTime, after turning “void FixedUpdate()” back into “void Update()” everything is working as expected. Thank you so much!