Goblin replaced by knight when updating BaseCharacter Tick Function

Hi All,

As the title states, when I update the BaseCharacter.cpp tick function to handle leftright checks, movement, and velocity by copying code from my Character.cpp, my goblin texture is no longer being drawn. I am not sure why or how this happening.

Before Changes

Here is a screenshot of the program loading the correct goblin texture before the change to Character and Base Character is made.
UnchangedCharacterCPP

BaseCharacter Header

Character.CPP tick function before movement of if-else is moved to base character. (Direction has been update to velocity.)

BaseCharacter tick function before changes.

After Changes

BaseCharacter Tick is updated with code from Character.

Character tick function after moving if-else statement. (BaseCharacter tick function call is moved to bottom so velocity is not zeroed out for movement.)

Results in program functioning as intended, but my goblin has become a knight. ( Knights are over lapping in this screen shot.)
AfterBaseCharacterCPPUpdate

My though is that the initialization of Texture2Ds texture, idle, and run in the BaseCharacter header is overriding the Enemy class instance in my Main.cpp, where I am passing the idle and run goblin sprites to the Enemy constructor.

What truly confuses me is that there has been no change to Texture2D variables directly, the only change I can think of is moving the BaseCharacter tick function call to the bottom of the Character tick function.

How could I fix the issue of the wrong sprite being drawn for the Enemy Goblin instance?

Sorry if this is word vomit, but I am truly deeply confused as to what is happening.

Thank you for any help that you can provide.

Spencer

Fixed it. After examining the Enemy class header more closely I found that having the enemy texture variables set as idle and run was the issue because the knight textures over wrote them in the tick function. After changing them to idle_texture and run_texture the issue was resolved and my goblin friend returned.

1 Like

Good job working out the solution!

1 Like

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

Privacy & Terms