Hi everyone! It's me again. I was trying to spawn a fireball right after an animation played, but it wasn't working. I tried three different ways, but it didn't work. I tried calling it when the animation triggered, I tried calling it when the button was pressed, and I tried it with the AnimationPlayer. Are there any ways to call it through the AnimationPlayer? Or am I just out of luck?

Having a look at the script is needed to find the problem.

Right . My bad.


extends state_node

const JUMP_FORCE = 15
var y_velo = 0
var GRAVITY = 0.98
var MAX_FALL_SPEED = 30
func physics_process(movement_key):

var grounded = Vector2(0,0)

y_velo -= GRAVITY
var just_jumped = false

if "8" in movement_key:
	just_jumped = true
	y_velo = JUMP_FORCE
if grounded and y_velo <= 0:
	y_velo = -0.1
if y_velo < -MAX_FALL_SPEED:
	y_velo = -MAX_FALL_SPEED
	print("jumped!")


return true

This is what I have so far. I'm using a state machine to control the states. This is the state for when it's jumping. I'm trying to get a fireball to spawn after th jump.

If I wanted to spawn a projectile. I would make that projectile a scene of it's own. Then instance it when the fire button was pressed. Even though the AnimationPlayer will animate a fireball, this is not the way I would do it. The fireball is programmed to do dmg on contact of an enemy, and move forward. After this dmg it is then .free() on itself.

@newmodels said: If I wanted to spawn a projectile. I would make that projectile a scene of it's own. Then instance it when the fire button was pressed. Even though the AnimationPlayer will animate a fireball, this is not the way I would do it. The fireball is programmed to do dmg on contact of an enemy, and move forward. After this dmg it is then .free() on itself.

I've tried that, but for some reason it doesn't work. This might be because It takes multiple inputs for a specific thing to work. That's why I thought there could be a way to spawn from the animation player.

How did you spawn it. You called instance. Then did you add it as a child to the scene. It will not show unless it is added to the scene tree.

11 days later

@newmodels said: How did you spawn it. You called instance. Then did you add it as a child to the scene. It will not show unless it is added to the scene tree.

Yeah that one was my bad. Sorry about the late reply, some things went on. The issue is fixed though! Although a new one has arisen.