Hiya!

I'm trying to use a script that will keep track of a bunch of numbers for me, so that I can use the same base stats and calculations for every character of the same type. I want move_speed to be influenced by dexterity and (not implemented yet) max_health to be influenced by strength, among other things.

I've already ran into a roadblock in that I seemingly can't get my PlayerCharacter's move_speed to become faster when I up their dexterity. So, I was wondering if anyone here could let me know what I'm doing wrong. I'm very new to programming, so any help would be incredibly appreciated, thanks!

  • I don't see a call to the function calculate_move_speed(). That could be placed in _physics_process() before the call to move_and_collide().

I don't see a call to the function calculate_move_speed(). That could be placed in _physics_process() before the call to move_and_collide().

    DaveTheCoder
    Oh wow, yeah, that was it. Can't believe I actually just forgot to call the function. Thanks for pointing it out!

    I figured placing it in _physics_process() would needlessly call it too many times, so I placed it in a new _ready func. That's fine, right? I'll just need to call it again whenever the player levels up and stuff, I think.

    That's correct, if dexterity is only changed manually in the Inspector, and you re-run the project after changing it.

    If dexterity gets changed by a script, then you would need to call calculate_move_speed() whenever that happens. (If you want to get fancy, you could define a custom setter for dexterity that handles that. But don't worry about that if you're a beginner.)

    To add to what @DaveTheCoder said, _ready() is only called when the node becomes ready after having entered the scene tree.