Godot Version
4.41
Question
Hi! I’m a very green indie dev making a 3D platformer and the goal is to have the goose approach an object, pick it up (& queue free it) which will then change the sprite so that it’s holding the powerup, which they can then use, (float powerup) and once they land again they turn back into a regular goose. I got my code to work ONCE and then never again, can someone help me figure out what I’m doing wrong here?
In the powerup:
[normal first few lines of base code]
func _on_area_3d_body_entered(body: Node3D) -> void:
if body.is_in_group("player"):
body.carry_nut()
queue_free()
This so far has allowed me to change the sprite upon pickup and causes the powerup to go away, where I’m struggling is that once I’m in the carry_nut() state, I can’t access the powerup in its code in my playerscript:
In the playerscript:
@export var is_goose = true #base goose state
@export var has_nut = false #change to carrying nut
@export var is_plane = false #is paper plane
[usual physics, move_and_slide, etc]
func become_goose():
is_goose = true
sprite_3d.texture = load("res://goose.png")
func carry_nut():
has_nut = true
print("i have the nut!")
sprite_3d.texture = load("res://Headshot.png")
func fly():
if has_nut and Input.is_action_just_pressed("use item"):
is_plane = true
print("fly!")
fly_up()
if Input.is_action_just_released("use item"):
fly_down()
if is_plane and is_on_floor():
become_goose()
func fly_up():
sprite_3d.texture = load("res://plane.png")
velocity.y += 10
func fly_down():
velocity.y -= lerp(2, 1, 0.5)
It isn’t recognizing my keystroke as an input in fly(). Any help would be greatly appreciated, as it did what i wanted it to do once, then stopped ![]()
Thanks,
rabbitrabbitgames