0 votes

Hey all,

So this is my first time playing around with Godot or game engines in general. I followed along with the tutorial documentation for the 2D and 3D game and was able to update it accordingly for the changes for the version 4 beta.

After following the 3D game tutorial I decided to make a handful of changes to make the game a little better. One of those things is adding a squish animation to the little creeps when you jump on their heads. I figured this would be an easy change since the tutorial showed us working with animations. For some reason though, this animation I created doesn't seem to play when I call play(), or is the animation_finished signal triggering to get the creep to disappear.

Here is the code for the mob:

extends CharacterBody3D

signal squashed

@export var min_speed = 10
@export var max_speed = 18

var velo = Vector3.ZERO

func _physics_process(delta):
velocity = velo

func initialize(start_position, player_position):
look_at_from_position(start_position, player_position, Vector3.UP)
rotate_y(randf_range(-PI / 4, PI / 4))

var random_speed = randi_range(min_speed, max_speed)
velo = Vector3.FORWARD * random_speed

velo = velo.rotated(Vector3.UP, rotation.y)

if $MoveAnimation.is_active():
    $MoveAnimation.playback_speed = random_speed / min_speed

func _on_visible_on_screen_notifier_3d_screen_exited():

func squash():
velo = Vector3.ZERO
$CollisionShape3d.disabled = true


func _on_squash_animation_animation_finished(anim_name):

Its a really short like .3 second animation that just scales the creep down flat. If the code for the other parts of the game are needed I can post them here.

Godot version 4.0
in Engine by (12 points)

I think you should provide the name of the animation to be played to play() function.

Oh sheesh. what a simple fix. Thank you!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.