#https://www.youtube.com/watch?v=it0lsREGdmc&t=5036s anyone help me with this tutorial

1 messages · Page 1 of 1 (latest)

floral vortex
#

show the script for the axe and I will try to help

dark skiff
#

Okay thank you

#

@export var player: Player
@export var Animatedsprite2d: AnimatedSprite2D
@export var hit_component_collision_shape: CollisionShape2D

func _ready() -> void:
    hit_component_collision_shape.disabled = true
    hit_component_collision_shape.position = Vector2(0, 0);

func _on_process(_delta : float) -> void:
    pass


func _on_physics_process(_delta : float) -> void:
    pass


func _on_next_transitions() -> void:
    if !Animatedsprite2d.is_playing():
        transition.emit("Idle")

func _on_enter() -> void:
    if player.player_direction == Vector2.UP:
        Animatedsprite2d.play("chop_back")
        hit_component_collision_shape.position = Vector2(0, -18)
    elif player.player_direction == Vector2.RIGHT:
        Animatedsprite2d.play("chop_right")
        hit_component_collision_shape.position = Vector2(9, 0)
    elif player.player_direction == Vector2.LEFT:
        Animatedsprite2d.play("chop_left")
        hit_component_collision_shape.position = Vector2(-9, 0)
        
    elif player.player_direction == Vector2.DOWN:
        Animatedsprite2d.play("chop_front")
        hit_component_collision_shape.position = Vector2(0, 3)
    else:
        Animatedsprite2d.play("chop_front")
        hit_component_collision_shape.position = Vector2(0, 3) 
        
        hit_component_collision_shape.disabled = false

func _on_exit() -> void:
    Animatedsprite2d.stop()
    hit_component_collision_shape.disabled = true
#

it goes red like this when u load the game and use the axe but if u move and try again it no longer goes red and is also not chopping the trees i have tried debugging to see what parts of the code are running and are not and im completly lost as i have rewatched this part of the video 5 times lol

floral vortex
#

why are you doing this hit_component_collision_shape.disabled = true in the ready function?

dark skiff
#

This is what he added in the video

floral vortex
#

what is the player script looking like

dark skiff
#
class_name Player

extends CharacterBody2D
@onready var hit_component: HitComponent = $HitComponent

@export var current_tool: Datatypes.Tools = Datatypes.Tools.None

var player_direction: Vector2
floral vortex
#

this is all for the player script?

dark skiff
#

one sec

floral vortex
#

this code structure seems very strange to me, is there a reason why you are following this tutorial specifically?

#

Are you pretty new to programming in general?

dark skiff
#

I know php oop a little

#

but like im getting no errors or anything to work with

dark skiff
#

Tbh looked up to date and easy to follow lol i just want to make a game like pot farm that was taken of facebook years ago lol

#

i could make it just using php but limited to what i can do and want to expand my learning

#

Ok so i fixed one issue the detector not going red in all directions

#
        
    hit_component_collision_shape.disabled = false ```
#

i needed it to be like this

#

not ``` hit_component_collision_shape.position = Vector2(0, 3)

        hit_component_collision_shape.disabled = false```