#Code not Emitting Enum Change

18 messages · Page 1 of 1 (latest)

stark hedge
#

if your code is like that you are missing some indentations in the second funciton after the if

stark hedge
#

Use swift to format the code

signal dustBOT
#
Embedding code in discord messages
Inline Code

When you surround some words with single backticks like `this`, it will be formatted as code.

Code Blocks

You can also include code blocks by surrounding the code with three backticks. If you add "swift" then you will also get basic syntax highlighting:
```swift
print("hello world")
```
Discord will then show it as a code block like this:

print("hello world")
Upload

If your code snippet is rather long, you can upload it to a text paste site. One option that supports syntax highlighting for GDScript is https://bpa.st/

feral valve
#

Isn't due to your order of calling or an another function consuming the new_state ? Don't really see events or call from one to another.

feral valve
#

Try print the current state, maybe it is calles twice and reset the state ?

gusty roost
#

Sounds like your state is being set to something else in-between hit and change_animation_state. What state does it give you instead? Could be a hint.

strong veldt
#

this is probably the hint that your current_state is not what you think it is

#

put print statement before any of those if statements and see what the value of current state is

gusty roost
#

Also, restructuring your code a little can make debugging a lot easer:

func change_state(new_state: State):
  current_state = new_state
  print(current_state)

Now you can see every time the state changes. There may be a swtich you didn't expect

strong veldt
#

is it able to enter into this code block then?

#

then your state is not new_state.Hit at the time that the checks happen

#

otherwise it would enter that code block

#

so, my guess is that your functions/events may not be running/firing in the order that you expect them to be

#

start putting break points everywhere where state changes and where checks for state occurs

#

then verify that the order of events/functions is what you expect it to be

#

step through it line by line and make sure code is executing EXACTLY how you think it should be

#

my guess is you'll find something along the way that wont be firing in the order you expect

#

Debugging your game is an important part of game development. Godot provides an easy-to-use debugger to help you debug. In this video, I'll teach you how to use the debugger, use print statements, and set breakpoints to fix issues and bugs in your Godot game.

👋 Join the community Discord: https://discord.gg/e4BxZbe

☕️. If you find the content...

▶ Play video