[SOLVED] Scorpion tail made of separate objects

Imagine we have enemy with scorpion tail
image

Where it is not a straight line but made out of separate objects
Like it was made in old games
image

Now i could do it by simply make that tail by placing each objects related to 1st object closest to enemy

But what if i want to change from lets call it idle position on the left to attack position on the right?

I saw chain example i am aware i would need to make joints or something like that
But my problem is is there some way to go from curved banana shape to straight stretched line and vice-versa
So it is not like lifeless chain and act as actual tail?

I do not not mean it being instant but move like actual tail
So for example with some formula i would control only position of piece with sting while other pieces would form curved shape when idle
But form straight line when stretched for attack
So shorter whole tail is (piece with sting is closer to tail) more curved it gets
And more far away it is then it forms more of a straight line

I would think you could achieve that with physics objects and a revolute joint between 2 adjacent tail pieces. You’d then move the stinger piece, and the others would follow. To get it to arc back you could use angle limits on the joints, so they bend one way and not the other.

Another option would be to tween each tail piece from its arched position to the extended position (positions would be relative) and then back again. I’m not sure how this would look, but if it was fast enough it may not be an issue.

That is exactly why i came here
I have idea for how to do it
I have problem with exact way

Like i know how to make cake
How many eggs and flour and butter to add

Idk when and how to mix them and why

I am perfectly able to do what is on the left but not what is on the right
ezgif-5-fe08099fe7

I was trying to figure out how to align the objects to a curve but that’s tough because they bunch up or spread out based on the shape of the curve. Maybe we’re overthinking it. How about just using several animations? It could attack from the same distance. So, maybe just do something like a few with different target heights or angles or maybe rotate that part like a joint to do the aiming. The idle animation can have a little bobbing up and down motion and then either pick a random attack animation for variety or pick one based on the target height or maybe distance. IDK. I don’t know if it needs to be too accurate.

You need to fix the last tail piece to the scorpion body. Have a look at my Rope Physics example. If you remove the gravity scale of the link pieces and set some rotation limits, then I think you could get something half decent.

Additionally you can add multiple joints at the same place to strengthen the joint and reduce or even prevent the gaps between segments.

@Keith_1357 This is not for me but for other user and his english is poor saying it lightly
He do not want to go with animations because stretching this tail for attack would require few frames but for very single other motion it would be painful to account for all since its gonna be boss
So this is his last option

@MrMen You assume my level of knowledge is higher than it actually is
I know you see me helping here but i did not explore a lot of stuff and it may sound like i know a lot while truth is i just know some stuff

And i never did explore physics i have problem with equations and formulas
My only success was to make bouncing coins with physics by trying every single possible combination in physics window for coins and floor

So i have no idea how to limit rotation?
I do not even know how to make joints take position based on joint with stinger
I did remove gravity and i got this

I do not need any1 to do it for me
I need someone example from which i could build upon
Like expressions to use equations formulas
I can mess with it and find my way around it
But i 1st need to know what to do

Imagine you want object to follow your cursor but like 20 pixels behind it
You know that you need to use change position action
You know that you need to put somewhere CursorX() CursorY()
But how to account for 20 pixels and where to put that thing that would make it stay 20 pixels behind?

That is my problem i know only what i need to do
I lack practical knowledge of how to do it

1 Like

I like the chain. I just don’t know how to restrict the joints to add the right look. I kind of want to wrap it around a circle with physics. The circle would support the links. Maybe you can shrink the circle as the first link is pulled.

My other idea was inspired by this other post.

https://forum.gdevelop.io/t/stretchy-neck-effect-solved/53977/4?u=keith_1357

The 2nd playable link shows how objects are added and removed. Othwise, the objects are aligned from point to point using an index or object variable to place it. The only issue is the shape.

In this post I talked about aligning objects to a curve but the spacing is an issue because they bunch or spread out.

MrMen mentioned aligning objects to a Bezier curves. I never did that. A Bezier curve or spline might work better.

Or a chain with limits and some sort of support.

@Keith_1357 Bless you for you considering we are overthinking
@MrMen Bless you for that rope example i did seen it many times i even have it saved in case i will ever need it

Anyway i can’t count how many times i told ppl on discord not to do something the way they wanna do it but any way that will fake the effect
Cause it does not matter how you do something it matters only what player will see
For example do not delete coins after you pick them up cause if you want to respawn them either you will need to save each coin X and Y or reset scene
So instead change their opacity to 0 and allow them to be picked up by condition coin opacity is equal to 255
Player will see coin disappear and will not care how it was made
While you simply change all coins opacity back to 255 when you die and nothing to for you to respawn there other than your player

And guess what?
I did not listen to my own advice
Damn me
Check this out

And look what it do
2024-04-22_15_53_l0I0PtHi3u_GDevelop

LMB to attack
Tilde (button above tab and below esc key) to reset scene

This is not dynamic the way physic chain would be but for faking tail physic i say it is spot on
Where that guy for who it is is making Mega Man X clone so 16 bit graphic would fit perfectly
Actually that gif with scorpion tail in my post above is what he made

And now
Correct me if im wrong but i know i am right but let’s just take a moment to sink into shame of simplicity
AngleBetweenPositions Current piec and Previous piece
With some offset like idk - some number
And now i smoothly am rotating each tail piece
Eh?

Where now he will only need to prepare events for enemy facing left and right
While add some variables for different animations
If any but i guess it will be way easier than making it via animation
Since there are only few places to adjust crap here
I could even go with more complex formulas to have only 1 formula for each piece depending of its ID variable (i mean he will need to give them vars)
But since it is just one boss object and there will be 1 or at best 2 fights with it there is no point in going that far

I also think only stinger piece should be positioned based on player where all other pieces positioned based on stinger piece

Done wrong way (meaning not in a way it would sync each frame but with wrong events order so it sync every other frame)
Tail would get kinda of 1 frame lag and jiggle a little faking it not being stiff object
I am open for any suggestions

But i think this will be enough for him i go show him this

Again Bless you guys

1 Like