Enemy moves at same speed as knight

I’m stumped with this one - once we moved the velocity calculation into BaseCharacter’s tick function, my goblin started moving at exactly the same speed as the knight. In the video, the instructor’s goblin still moves slower, but mine is definitely at the same speed. I suspect this is because we’re now calling BaseCharacter::tick(deltaTime), and speed is defined in BaseCharacter.h as 4, so both the goblin and the knight are using that same value. That doesn’t make sense to me, however, because I have speed defined as 1 in enemy.cpp, and BaseCharacter.h is loaded before that definition, so the new value (of 1) should win out when calling the base character tick function, unless BaseCharacter::tick(deltaTime) also is somehow reloading all of the values from BaseCharacter.h. I’ve spent an hour and a half trying different things and trying to think through this, but so far nothing has worked. Hopefully somebody can identify what’s going on and why the goblin was slower in the instructor’s video but not mine! I’ve only included the .h and .cpp files for BaseCharacter and enemy, since I’m guessing the problem is in one of these four.




You’re redefining speed as a local variable in the enemy constructor. Try speed = 1.f; instead.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms