8 Directional 2D Character Movement Setup ~ Godot 4 Tutorial

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ •

  • @GAFProductions-v7g
    @GAFProductions-v7g 3 місяці тому +4

    God bless you my brother, you helped me in an unimaginable way and at the right time, thank you very much

  • @skepsys_d
    @skepsys_d 3 місяці тому +3

    Very cool good sir.

  • @Fighka303
    @Fighka303 2 місяці тому +2

    (if you're making an Isometric game)
    class_name Player
    extends CharacterBody2D
    @export var speed : float = 50
    @export var animation_tree : AnimationTree
    var input : Vector2
    var playback : AnimationNodeStateMachinePlayback
    func _ready() -> void:
    playback = animation_tree.get("parameters/playback")
    func _physics_process(_delta: float) -> void:
    input = Input.get_vector("left", "right", "up", "down")
    var iso_input = Vector2(input.x * 2, input.y)
    velocity = iso_input.normalized() * speed

    move_and_slide()

    select_animation()
    update_animation_parameters()
    func select_animation() -> void:
    if velocity == Vector2.ZERO:
    playback.travel("idle")
    else:
    playback.travel("walk")
    func update_animation_parameters() -> void:
    if input == Vector2.ZERO:
    return

    animation_tree["parameters/idle/blend_position"] = input
    animation_tree["parameters/walk/blend_position"] = input

    • @polkulotznad3987
      @polkulotznad3987 7 днів тому +1

      why my character keep walking even i released key?

  • @100degeneracy7
    @100degeneracy7 2 місяці тому +1

    Im having issues getting it to play other animations, almost like the blend space position is stuck in one spot and whether input is given or not it'll stay in the same spot.
    If you have any ideas i would love to get some input

    • @100degeneracy7
      @100degeneracy7 2 місяці тому +1

      Got mine to work, for some reason assigning the Input.get_vector() to direction or as you call it input will give a coord but once assigned to blend position it would create a null value. To bypass this i just assigned Input.get_vector() directly to the blend position coord

    • @dappapanda
      @dappapanda 2 місяці тому

      @@100degeneracy7 can you further explain, mines is just playing the first animation assigned, it would also help if you could show your code

    • @100degeneracy7
      @100degeneracy7 2 місяці тому

      @@dappapanda make sure you have an animation key frame assigned with the frames in animation player, click on the animation key frame and you can assign other animations to the key frames. if you're passing Vector2 into a var like direction and then using direction to change blend position it seems to come up null and default the blend position to (0.1,0.1).

    • @meg._.09
      @meg._.09 25 днів тому

      @@100degeneracy7 i still don't understand, do i need to change something with the code or???

  • @Prashant-yj4on
    @Prashant-yj4on 3 місяці тому

    Great video!! Wondering if the animation for platformer video is still relevant or needs to be updated

  • @BillyWestbury
    @BillyWestbury 3 місяці тому

    Great tutorial, very well explained as always, could you do the same with a non top down RigidBody2d player ?

  • @deesha7359
    @deesha7359 3 місяці тому

    can u plz make a video about cut scenes like a story before the boss

  • @meg._.09
    @meg._.09 25 днів тому

    my stays on walk left if I'm moving or not. how do I fix it??

  • @xxnekonekox
    @xxnekonekox Місяць тому +1

    how do i go from 8:40 to 8:42?

    • @minerva-gd
      @minerva-gd Місяць тому

      It took me a minute to figure it out, but there is a little pencil icon next to the word idle in the blendspace2d box we created.

  • @alexseyrozhon686
    @alexseyrozhon686 25 днів тому

    Thx u bro! U have helped me to solve my big problem! Like & sub

  • @polkulotznad3987
    @polkulotznad3987 7 днів тому

    my characters keep walking even i already released key

  • @Fighka303
    @Fighka303 2 місяці тому

    also thank you

  • @dmanit3559
    @dmanit3559 2 місяці тому

    hi sir, im having error to one of you video tutorial. could you help please? the one with the blue slime
    please help!!, Unity user.
    im having this error " NullReferenceException: Object reference not set to an instance of an object
    PlayerControls.EndSwordAttack () (at Assets/PlayerControls.cs:121)
    "
    after i put this code
    public void EndSwordAttack() {
    UnlockMovement();
    swordAttacks.StopAttack();
    }