#bug

7 messages · Page 1 of 1 (latest)

solemn hedge
#

so uh i was working on this farming game and the plant wont stop growing
code:

extends StaticBody2D

var plant = Global.plantselected
var plantgrowing = false
var plantgrown = false

func _physics_process(delta):
    if plantgrowing == false:
        plant = Global.plantselected


func _on_Area2D_area_entered(area):
    if not plantgrowing:
        if plant == 1:
            plantgrowing = true
            $CarrotTimer.start()
            $plant.play("carrotsgrowing")
        if plant == 2:
            plantgrowing = true
            $OnionTimer.start()
            $plant.play("onionsgrowing")
    else:
        print("plant grown!")



func _on_CarrotTimer_timeout():
    var carrot = $plant
    if carrot.frame == 0:
        carrot.frame = 1
        $CarrotTimer.start()
    elif carrot.frame == 1:
        carrot.frame = 2
        plantgrown = true


func _on_OnionTimer_timeout():
    var onion = $plant
    if onion.frame == 0:
        onion.frame = 1
        $CarrotTimer.start()
    elif onion.frame == 1:
        onion.frame = 2
        plantgrown = true




func _on_Area2D_input_event(viewport, event, shape_idx):
    if Input.is_action_just_pressed("click"):
        if plantgrown:
            if plant == 1:
                Global.numofcarrots += 1
                plantgrowing = false
                plantgrown = false
                $plant.play("none")
            if plant == 2:
                Global.numofonions += 1
                plantgrowing = false
                plantgrown = false
            else:
                pass
        print("number of carrots: " + str(Global.numofcarrots))
        print("number of onions: " + str(Global.numofonions))

i am following this tutorial: https://www.youtube.com/watch?v=QK_uI-m6bpA&list=PL3cGrGHvkwn3zyVj-lHM1aGYhNv8E0HBS&index=3

In the video today you will be taught step by step how to create working plants/crops work in Godot, and I will be teaching you the best way to create working crops and collected them as well. A ton of info so I know you will learn a lot

Welcome to the most important video series you will ever watch on Godot game development. So much will be le...

▶ Play video
#

ok

#

thanks

#

but new error

#

@true dove

#

new error

#

bug