How to Create An Advanced ENEMY In Godot 4

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 104

  • @SleepyMcGee
    @SleepyMcGee 11 หลายเดือนก่อน +27

    Nice video man!
    I've got a few tips/suggestions though.
    Instead of using `has_method`, and adding dummy methods for making sure you are looking at a particular type of object, you could use `class_name`.
    So you would have, for instance `class_name Player` at the top of your file, and then check `if body is Player`. This way you don't have to add an empty function. It also has the added benefit of making it appear in the node search, which can be very useful if you want to create, say, a reusable health or hitbox component.
    I would also caution against hard coding damage values in your `_on_hitbox_area_entered` function. This kind of system could become very unwieldy once you have multiple enemies. Say you have 5 different enemies and then decide that, actually arrows should do 60 damage. You now have 5 places you could forget to update it.
    A better system might be to keep that info in the arrow itself, and access it when you are applying damage. So you'd have `take_damage(weapon.damage)` in your function, and only one place to update if you think arrows should do more or less damage.

    • @ReeseTheTechGuy
      @ReeseTheTechGuy 10 หลายเดือนก่อน +5

      Another approach I've seen out there as an alternative to has_method is to place the player into a group such as "Player". You can then just call `body.is_in_group("Player")`

    • @GaryParkin
      @GaryParkin 10 หลายเดือนก่อน +2

      I added your idea for the player class name and it worked as you said (thank you) but I also left the player has_method in case I had a function that needed to call a function on the player. No idea if that's right or not, but it works.
      I read in so many places not to use or rely on groups because forgetting to add something is a nightmare debugging. The class name just works.
      And I totally agree on having the arrow pass the amount of damage to the enemy. What if you used wood arrows vs. metal arrows. :D

    • @Ryxbar
      @Ryxbar 7 หลายเดือนก่อน +3

      putting the damage variable on the arrow is definitely the way to go. This series is definitely geared towards complete noobs like me who can more readily follow the hardcoding style of having the relevant variables on the thing that's interacting with them, and it's great for teaching in a small environment like this, but scaling this up to a bigger project would be exhausting. Thanks for the pointer, I've moved my damage stat over to the arrow and it works great ^.^

    • @whirlin22
      @whirlin22 3 หลายเดือนก่อน

      for anyone else wondering how to implement damage from the area, you need a var damage = 50 in the arrow node and then when the slime detects the arrow area, you can call take_damage(area.damage)

  • @godotgamelab
    @godotgamelab 11 หลายเดือนก่อน +12

    This series is really well made, thank you for creating high-quality content fellow TH-cam teacher! 😊

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน

      Hello fellow TH-cam teacher! So happy to hear that!! Thanks!!!

  • @GaryParkin
    @GaryParkin 10 หลายเดือนก่อน +5

    Thank you, this one worked perfectly. But if I may; I changed the death of the slime to spawn the slime_collectable then queue_free, just like the code in the apple tree. Brilliant,.
    Then I set up the slime_collectable just like the stick so it just sits there waiting for the player to walk over it and pick it up. It seemed more natural that way.
    I am so thankful of your little apple tree video. I'm not a fan of 2D but I've learned so much so far.

    • @Ryxbar
      @Ryxbar 7 หลายเดือนก่อน

      this is the way I chose to set it up, but I'm glad this video exists anyways because it shows a different approach that may be useful later, for say if you want to guarantee a boss drop goes in your inventory so you don't accidentally walk away without it. Very cool, thanks for the idea!

  • @planktime
    @planktime 10 หลายเดือนก่อน +7

    Hey DevWorm, First thanks for making this series its fun and informative. For the slime loot. I think one could also have the slime's death instantiate a copy of the slime collectible scene. Model it off of the stick resource then the player can pick it up by hitting its collision shape. This might save some time with disabling the slime collectible and its collision shapes. It would also prevent the crash if the player did not enter the collision shape 2d on the slime itself.

    • @dev-worm
      @dev-worm  10 หลายเดือนก่อน +1

      just realized it did that... sorry.. your right. It wouldve been so much better to do it that way.

  • @Zahardnik3
    @Zahardnik3 8 หลายเดือนก่อน +3

    Another tutorial completed. Thanks DevWorm!

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +3

      thanks brother!! means the world!! you don't have to!! much much love to you! It means the world @Zahardnik3

  • @panwladca8800
    @panwladca8800 6 หลายเดือนก่อน +2

    Youre a great guy bro, once i get my finances back on track i will send you some donations , very informative and i like how you correct your mistakes and explain the logic in a very understandable way for someone like me who is just getting started. ❤

    • @dev-worm
      @dev-worm  6 หลายเดือนก่อน +1

      aw dont worry about the money brother! just learn! I'm here to try and teach.. you should save that money and work with a professional developer one-on-one! but it means the world that you find these tutorials helpful! thank you and with your determination to improve you are going to do something truly amazing!

  • @Memose2
    @Memose2 11 หลายเดือนก่อน +3

    🎉🎉 finally new video !

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน +1

      looking to get really consistent!! thank you so much for watching! Hope it was able to help!

  • @geovanyhernandez8640
    @geovanyhernandez8640 4 หลายเดือนก่อน +2

    If anybody was having issues with the calculation of the player position in Godot 4.2, this is what worked for me:
    position += (player.position - position).normalized() * speed * delta
    Idk what was happening, but the enemy seemed to move out of the screen and get stuck

  • @halasfil
    @halasfil 11 หลายเดือนก่อน +12

    I think you could fix the issue with sprites being blurry so it will look a bit clearer (Texture->filter->change to: nearest)

  • @PunCala
    @PunCala 11 หลายเดือนก่อน +2

    Thank you once again! Also, some more topic suggestions: how to create cutscenes (character animations, camera movement etc.).

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน +1

      Thanks for the idea! Ill starting working on it right now and Ill try to have the video out within the next 2 days!

  • @BrunoFernandes_84
    @BrunoFernandes_84 8 หลายเดือนก่อน +1

    I think, and im a bit newbie, that u could simply drop the slime collectable and work with it like the stick, if u pass through u pick it if u don't it disappear after certain time, because we could not want to pick some type of drops... but anyway gj im learning a lot, hope u can keep with the series :)

  • @NexusBaum
    @NexusBaum 11 หลายเดือนก่อน +1

    the audio is perfectly fine
    good job!

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน

      happy to hear! thank you so much!

  • @affanhocaoglu7835
    @affanhocaoglu7835 หลายเดือนก่อน

    Thank you. This fixed my problem.

  • @Chris-L878
    @Chris-L878 6 หลายเดือนก่อน +1

    Hello, Ive just recently got into coding and found this tutorial its super helpful and clear but I noticed there was no damage for the player any suggests on how i might add that thanks ❤

    • @dev-worm
      @dev-worm  6 หลายเดือนก่อน

      so just like when we created damage for the enemy, it is along the same lines of that! instead you have to put an area2d on the arrow and connect it to check if it enters the player.. and if so then you can change a health variable and function whatever you want to happen when the health is changed or if it equals 0 then to hide the player or play the death function!

  • @jasoncrawford2224
    @jasoncrawford2224 9 หลายเดือนก่อน +1

    thanks for the videos!

  • @notoreofreakshake
    @notoreofreakshake 11 หลายเดือนก่อน

    you are the best teacher, i want you to play my first ever game i built after learning godot from you

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน +2

      I would be so glad to! Im so happy to hear that Im able to help you out!

    • @notoreofreakshake
      @notoreofreakshake 11 หลายเดือนก่อน

      @@dev-worm I have uploaded my code in github, is there anyway I can share it to you, you have a discord community?

  • @AnnualSeveral
    @AnnualSeveral 11 หลายเดือนก่อน +4

    These are cool but I'd love to see some design patterns applied ❤

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน +1

      thatd be cool! ill look into it right now!

    • @AnnualSeveral
      @AnnualSeveral 11 หลายเดือนก่อน

      @@dev-worm happy to do some ensemble collaboration if you're interested. Basically we rotate as driver/navigator while we work on a game. 🙂
      It's a process we use all day at work, I love it.

  • @Z0mbie432
    @Z0mbie432 6 หลายเดือนก่อน

    thanks broseph!

  • @volmie
    @volmie 9 หลายเดือนก่อน

    Can I ask why you chose to use the giant collision shape to find the player as opposed to an onready variable with the get_node() function & an absolute path to the player?

  • @argonauta128
    @argonauta128 11 หลายเดือนก่อน

    Congratulations on another impeccable video. Now I have a very lively enemy to fight against.
    I just have one suggestion and one question.
    Suggestion: for future videos, it would be very kind if you tried to keep the script window a little larger to make viewing easier (just a note from a follower with low vision).
    Question: when I get the second slime, the label number appears behind the slime icon in the inventory. This only occurs for slimes, the number of apples and sticks appears over the respective icons. Could you instruct me on how to fix this?
    Thank you very much

    • @argonauta128
      @argonauta128 11 หลายเดือนก่อน

      reviewing the previous videos, I realized what might be the source of the problem: in the inv_UI_slot scene I added item_display as a child of CenterContainer and not as a child of Panel. However, when I simply try to pull and release item_display to make it a child of Panel (prior to Label), the game breaks, no longer running in DEBUG. Please, what procedure could I take to fix this without breaking the game?

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน +1

      hmmm.. uh i would have to think that a certain slot is messed up but if you've played the game and picked the items up in different orders and it is still only messing up with slimes then I'm not sure... I'm sorry but id have to look at it. I'm very sorry. if you still haven't got it resolved then try and explain it a little more and maybe I could figure it out by looking at my copy of the game. i'm really sorry and i hope im able to help!

    • @argonauta128
      @argonauta128 11 หลายเดือนก่อน

      @@dev-worm Many thanks for the reply. There is no need to worry about me in this regard. After you finish your course here, I will redo everything once again, so that I can better understand the processes and concepts in my mind. I have no training in this area and I am learning completely from scratch with some tutorials here on TH-cam. It's worth pointing out that your videos have been the most inspiring and productive for me. Please keep up the great work!

  • @MijmerMopper
    @MijmerMopper 9 หลายเดือนก่อน +1

    Im sorry to say I am encountering the same issue as I had in the video about creating an enemy as part of your creating an RPG tutorial. The enemy just yeets off into the distance when I enter the detection_area CollisionShape2D. Changing the speed (counterintuitively making the var a bigger number so it walks slower, because of the divide by speed in line 19) it walks right past me on to bigger and greater adventures. I know I haven't even added in the attack animation at this point, but this enemy is just being really passive aggresive about it!

    • @jackygreenhow9889
      @jackygreenhow9889 7 หลายเดือนก่อน +1

      hi. i had this issue, then realised the issue. i had "possition += (player.position - position / speed)" instead of position += (player.position - position) / speed

    • @danscousincousinsdad699
      @danscousincousinsdad699 6 หลายเดือนก่อน

      @@jackygreenhow9889 thanks man

  • @garrettmcneill1603
    @garrettmcneill1603 3 หลายเดือนก่อน

    Wondering, why wouldn’t you just create a preload reference to the collectible and then instantiate it, then queue free the actual slime. Would make you not have to deal with all the visible disabling and what not, and would be cleaner down the road like if you wanted to keep track of enemies in the world or collectibles in the world ( like when you want a enemy limit or minimum or when you want a collectible limit ). Then just give the collectible the same script as the stick

  • @minx-fractor
    @minx-fractor 5 หลายเดือนก่อน

    Broo it worked in 3d tooooo😊😊😊

    • @dev-worm
      @dev-worm  5 หลายเดือนก่อน

      so glad to hear!!

  • @planktime
    @planktime 10 หลายเดือนก่อน +1

    I kinda miss you starting off with "HELLO!"

    • @dev-worm
      @dev-worm  10 หลายเดือนก่อน +1

      haha.. "HELLO!" Ill make sure to have it in all the next videos.. and then remember that this comment is what revived the HELLO! lol

  • @martinithechobit
    @martinithechobit 11 หลายเดือนก่อน

    Wow thanks.

  • @Assem_DEV
    @Assem_DEV 11 หลายเดือนก่อน +1

    Can you explain about ,Inventory system in Godot 3.5. Because some devices do not run Godot 4

    • @Assem_DEV
      @Assem_DEV 11 หลายเดือนก่อน

      I like your explanation

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน

      sorry for the late reply, inventorys are complex and ill try and see what i can do

  • @AstriaTVTruthExposed
    @AstriaTVTruthExposed 5 หลายเดือนก่อน +1

    How would we add damage to the slime so that it can damage the player?

    • @dev-worm
      @dev-worm  5 หลายเดือนก่อน +2

      check out the recent "how to create combat system" that is part of the hack'n'slash series that I uploaded about a week ago!! It covers this really well!

    • @AstriaTVTruthExposed
      @AstriaTVTruthExposed 5 หลายเดือนก่อน

      @@dev-worm awesome thank you! Keep up the great work, I appreciate all the effort to help us new people!

  • @HighImHorizon
    @HighImHorizon 3 หลายเดือนก่อน +1

    im having abit of an issue with the collisions . for example, if i stand next to a collider and the slime pushes me, i will just clip through . and the slime just phases through all collisions on the tilemap.
    edit: i changed my collider on the player to a capsule shape and that fixed the first problem
    edit 2: just added move_and_slide( ) to the physics process and now slime collides .

    • @dev-worm
      @dev-worm  3 หลายเดือนก่อน

      it is amazing to hear that you were able to figure everything out!! goodjob!

    • @HighImHorizon
      @HighImHorizon 3 หลายเดือนก่อน

      @@dev-worm thanks :) I’ve still got a long way to go before Im out of tutorial hell though lol

    • @daridark2528
      @daridark2528 3 หลายเดือนก่อน

      @@HighImHorizon How did you manage to keep the enemy from moving when it leaves the detection area? In mine it moves down when I collide with the

  • @OGsyntry
    @OGsyntry 9 หลายเดือนก่อน +1

    Any idea on why I get the error "Invalid set index 'visible' (on base" 'null instance') with value type 'bool'. It doesnt like the code "drop_slime()", and "slime.visible = true". Ive gone back and double checked things but cant seem to find what I missed.

    • @simonlaghez
      @simonlaghez 8 หลายเดือนก่อน

      I've had this type of error too and it's just that I misspelled a word in the script, so check the spelling carefully.

    • @tylerstokes8698
      @tylerstokes8698 8 หลายเดือนก่อน

      I keep getting the same code but instead of "null instance" mine says "staticbody2d"
      Edit: My fix ended up being that I spelled Visible as Visable. The person above was right about spelling error. Hope that helps

    • @supjay3945
      @supjay3945 7 หลายเดือนก่อน

      Sometimes chatgpt can help scan edit your codes. But sometimes it will keep giving a bad solution

  • @MYTHICALFIN
    @MYTHICALFIN 5 วันที่ผ่านมา

    Fun fact: you can phase through really narrow places when the slime pushes you to a corridor or to a narrow place.. Try this yourself..

  • @Solarplex_edits
    @Solarplex_edits หลายเดือนก่อน

    Do the slimes kill you?

  • @jeremiahaemile2008
    @jeremiahaemile2008 11 หลายเดือนก่อน

    Cool man

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน

      thanks man!

  • @Programming_Of_All
    @Programming_Of_All 11 หลายเดือนก่อน +1

    Bro when are you gonna make the damage that we took from enemy?

    • @SlowHush
      @SlowHush 8 หลายเดือนก่อน +1

      that's very easy, you just have hitbox and health box nodes, and add them to the player and enemies, just set up the collision layers correctly so that they interact with each other. (I am using a translator, I speak Spanish). If you like, I'll give you the script for the created nodes.

    • @Chris-L878
      @Chris-L878 6 หลายเดือนก่อน

      ​@@SlowHushHi, would it be possible if i could have those scripts as well? im really lost, thank you​

    • @SlowHush
      @SlowHush 6 หลายเดือนก่อน +1

      @@Chris-L878 of course, with pleasure, just give me a moment and step script

    • @daridark2528
      @daridark2528 3 หลายเดือนก่อน

      @@SlowHush me los puedes dar xd? solo de ejemplo ando intentando hacerlo y como que no da

  • @Sewomer
    @Sewomer หลายเดือนก่อน

    Ich versuche das hier mal auf Deutsch. Ich habe folgende Probleme... 1. Wenn ich in der Range vom Slime einen Stock einsammel verschwindet auch der Slime (Enemy). 2. Seit ich das Arrow system eingebaut habe folgt mir der Slime nicht mehr.

  • @ashkurosaki7028
    @ashkurosaki7028 หลายเดือนก่อน

    I dont know why my enemy is running away from my character and i follow all your guidelines

  • @ashasonshine7050
    @ashasonshine7050 6 หลายเดือนก่อน

    I love your work. but I am hitting a snag. the slime is running away from my player. I followed it to the letter, but it seems to run.

  • @jeremiahaemile2008
    @jeremiahaemile2008 11 หลายเดือนก่อน

    man ,are you going to make video about godot 4.2
    this uptade awesome has alot of Abbreviation and alot of improvment for both three d and two d
    this uptade is very amazing you have to talk about it

  • @wash99
    @wash99 7 หลายเดือนก่อน

    bro what if i wanna add this to my platformer ??? i add gravity ?????????
    please enlighten me

  • @m4y0ch33si3
    @m4y0ch33si3 11 หลายเดือนก่อน

    is there a way to make a reflection shader? without using c#

  • @kilrath81
    @kilrath81 10 หลายเดือนก่อน

    You should be using velocity and move_and_slide(), not setting positions directly, otherwise they won't respect collision.

    • @dev-worm
      @dev-worm  10 หลายเดือนก่อน +1

      yes thats a good point, should've done that instead

    • @Chris-L878
      @Chris-L878 6 หลายเดือนก่อน

      Thanks that was helpful

    • @scoringfish1588
      @scoringfish1588 6 หลายเดือนก่อน

      I can’t figure out how to get it to work with that, how did you do it

    • @kilrath81
      @kilrath81 6 หลายเดือนก่อน

      @@scoringfish1588
      # Movement Speed Settings
      var speed : float = 0
      var speedup : float = 3 # Amount of speed to add while speeding up
      var slowdown : float = 3 # Amount of speed to subtract while slowing down
      # All movement related functionality goes here
      func handle_movement():
      var moveDirection = Input.get_vector("Move_Left", "Move_Right", "Move_Up", "Move_Down")
      ## Player movement handler
      ## If there is a movement direction increment speed by speedup and clamp to maxSpeed to avoid infinite speed increase
      ## Else the player is no longer commanding movement and we slow down the speed by slowdown. We increment down speed so
      ## that if movement is resumed while slowing down it increments up from where it was and not 0
      if (moveDirection):
      speed = clampf(speed + speedup, 0, statsManager.playerStats.maxSpeed)
      velocity = moveDirection * speed
      else:
      velocity.x = move_toward(velocity.x, 0, slowdown)
      velocity.y = move_toward(velocity.y, 0, slowdown)
      speed = move_toward(speed, 0, slowdown)
      move_and_slide()

  • @rremnar
    @rremnar 11 หลายเดือนก่อน

    I deleted my other comment as it was just me thinking out loud, and this isn't really the place for such a hypothetical discussion.
    Now there is a few things I wanted to point out.
    Your "dead" variable doesn't need to be initialized in the ready function. It is already initialized when you wrote it out.
    On your await function, you can have it wait for the animation_finished signal to trigger. Don't give it the name of the animation, it just doesn't work that way anymore, from my experience.
    When doing logical statements, you don't need to write a separate section for the true part. In fact you could have just put that before or after your if block, or use an else statement in your if block.
    If !dead:
    else:
    This is useful if you don't want certain code to execute unless the oposite of your if statement is true. This is just syntax suggestions, your way still works.
    To stop your animation in your death function, just call the stop function lol; you don't have to hide it.

    • @dev-worm
      @dev-worm  11 หลายเดือนก่อน

      yes your right.. i see what your talking about.. thank you for pointing these things out.

    • @GaryParkin
      @GaryParkin 10 หลายเดือนก่อน

      I could not find a way to know when the animation finished, so I set my timer to 0.8 seconds. There seems to be a signal but it never fired. AnimationPlayer works great but AnimatedSprite2D doesn't on my game.

  • @geovanyhernandez8640
    @geovanyhernandez8640 4 หลายเดือนก่อน

    Help :(
    I'm making a game where I'll have two groups fight each other. I used the same code from the video for the two groups but one's method is enemy and the other knight. However, if characters from the same method collide with each other, they kill each other (lol).
    Does anyone have any suggestion as to why that might be? I'm a noob at game dev. Thanks!

    • @lucasyoutubeplay921
      @lucasyoutubeplay921 4 หลายเดือนก่อน

      maybe you have to write:
      func _on_detection_area_body_entered(body):
      if body.has_method("player"):
      player_in_area = true
      player = body
      func _on_detection_area_body_exited(body):
      if body.has_method("player"):
      player_in_area = false

  • @lucasyoutubeplay921
    @lucasyoutubeplay921 4 หลายเดือนก่อน

    Hello, i have a problem that the enemy only collide with the player, no with the world or with other things.
    somebody can help me?

    • @dev-worm
      @dev-worm  4 หลายเดือนก่อน

      make sure everything is on the same collision layer, and that the enemy's mask is set to see that layer when deciding to collide!

    • @lucasyoutubeplay921
      @lucasyoutubeplay921 4 หลายเดือนก่อน

      @@dev-worm how can i configure the mask?

  • @tanex2792
    @tanex2792 11 หลายเดือนก่อน +1

    please teach how to make game end like when u die or when you win. I have a project that is due soon and i need learn how to do that part lol

  • @imjustepic4206
    @imjustepic4206 10 หลายเดือนก่อน

    Im curious is there a way to make it so the item that drops "slime" just disappears if im not in the detection area like if im far out of the area and end up killing the slime because i have a further camera zoom so i can see more... i kill the slime out of range it drops and crashes i know you maade the detection area to pick up the slime in a larger area but what if we wanted to just kill the slime and move on without picking up the item or just killing it from out of that range it would make the game crash any work around to that?

    • @GaryParkin
      @GaryParkin 10 หลายเดือนก่อน +1

      Hi! use the same code as dropping the apple. Make the slime_collectable scene just like the stick, so it's collectable and change the slime scene to instantiate it into the world, then queue_free the slime monster. Tha6t way you don't have that huge area to deal with and the player gets to collect the slime or not.
      You could set a wait timer on the slime_collectable to kill itself after a minute so it's not stuck in the world. :)

  • @sharifa0096
    @sharifa0096 6 หลายเดือนก่อน

    nooo don't do it

  • @Carmidian
    @Carmidian 5 หลายเดือนก่อน +1

    I am getting an error and a game crash with the line; position += (player.position - position) / speed
    Error; Invalid get index 'global' (on base: 'CharacterBody2d (player.gd)').
    I've tried using chat gpt to help me out but I still don't understand
    Edit;
    I went back to one of your old tutorials and added these two lines of code, I had to turn the speed down though;
    var direction = (player.position - position).normalized()
    position += direction * speed * delta

    • @Musaf05
      @Musaf05 4 หลายเดือนก่อน

      hey dude can you give me the final code and did it work?

    • @Carmidian
      @Carmidian 4 หลายเดือนก่อน +1

      @@Musaf05 Unfortunately I've changed PCs and don't have it anymore. However I found that chat gpt helps out a lot when you need questions answered

    • @Musaf05
      @Musaf05 4 หลายเดือนก่อน

      thanks dude

  • @Zahardnik3
    @Zahardnik3 8 หลายเดือนก่อน +1

    This is what I did to make the player have to go collect the dropped loot.
    In the slime script do this:
    func drop_slime():
    slime.visible = true
    $slime_collect_area/CollisionShape2D.disabled = false

    func slime_collect():
    slime.visible = false
    player.collect(itemRes)
    queue_free()
    func _on_slime_collect_area_body_entered(body):
    if body.has_method("player"):
    player = body
    slime_collect()
    Shrink down the rat_collect_area>CollisionShape2D so the player has to get to it.

    • @Zahardnik3
      @Zahardnik3 8 หลายเดือนก่อน

      It took me several tries to comment this. Apparently youtube doesn't like ".gd"

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      yes looks really good!! goodjob Zahardnik3.. im so happy to see you spending so much time trying to learn and get everything right!! it is really amazing to see!

  • @tomoyaokazaki2138
    @tomoyaokazaki2138 6 หลายเดือนก่อน

    I got an error for trying to collect the item.
    Invalid call. Nonexistent function 'collect' in base 'Nil'.
    I have no idea why it works for the stick and apple collectables, but not the slime_collectable from the Slime.
    It highlights this line of code:
    player.collect(item)
    It's supposed to work just like the stick (walk over it and you pick it up). The full function code is this:
    func slime_collect():
    await get_tree().create_timer(1.5).timeout
    slime.visible = false
    player.collect(item)
    queue_free()
    ---------------------------------------
    I basically copied and pasted for the same interactable area body code. I also have this code:
    @onready var slime = $slime_collectable
    @export var item: InvItem
    Can someone help me out, please? idk what to do, the system just doesn't view "collect" as a function. And yet, it views it as a function in my other scripts like for the stick and apple.

    • @Exodeon
      @Exodeon 4 หลายเดือนก่อน

      it means that your "player" variable is null (probably uninitialized)