0 votes

I tried using the code below but it doesnt seem to work as intended. Im trying to make a really bouncy ball projectile that will change shape depending on its speed. Any advice would really help!

func integrateforces(state):
var counter = [false,false,false,false]
var veclocity = abs(linear_velocity.y)
print(veclocity)

if veclocity >= 400:
    if counter[0] == false:
        $Skin.scale.y += 0.025
        counter[0] = true
    if veclocity >= 600:
        if counter[1] == false:
            $Skin.scale.y += 0.025
            counter[1] = true
        if veclocity >= 800:
            if counter[2] == false:
                $Skin.scale.y += 0.025
                counter[2] = true
            if veclocity >= 1000:
                if counter[3] == false:
                    $Skin.scale.y += 0.025
                    counter[3] = true

if veclocity <= 1000:
    if counter[0] == true:
        $Skin.scale.y -= 0.025
        counter[0] = false
    if veclocity <= 800:
        if counter[1] == true:
            $Skin.scale.y -= 0.025
            counter[1] = false
        if veclocity <= 600:
            if counter[2] == true:
                $Skin.scale.y -= 0.025
                counter[2] = false
            if veclocity <= 400:
                if counter[3] == true:
                    $Skin.scale.y -= 0.025
                    counter[3] = false
Godot version Godot Version 3.2
in Engine by (15 points)

2 Answers

+1 vote
Best answer

You´re thinking too complex.
Try something like this:

$Skin.scale.y = 1 + abs(velocity.y/400)
by (50 points)
selected by

This worked, thank you so much! lol I really did complicate it

+1 vote

Animation is a lot easier.
You will just create the sprites variations and change them as you fit.

by (232 points)
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.