Discuss Scratch

blender67
Scratcher
10 posts

Joint axes

How can I make a human-like leg using three sprites (the thigh, knee (or just a joint), and shin). It does not drop limp when not being dragged around, and it's length does not vary depending on the mouse's position
Birdlegs
Scratcher
1000+ posts

Joint axes

To make a rotating joint, it can generally work to place the costume center where the joint should be and then use the Go To block. But if you want multiple joints, an easy, non-trig way would be to have the jointed sprite go to the object, save its direction in a variable, point in the direction of what it's jointed to, rotate any necessary degrees, and finally step forward to the point it needs to join with. Then it should return to the orientation the variable saved. This might lag with lots of joints, so if you know trig, that's best, I think. Also, you might wanna run all that in non-refresh if it gets wonky.

Last edited by Birdlegs (May 28, 2015 01:42:15)


Get a sweet lick of my new game right here! It's a tasty one!
blender67
Scratcher
10 posts

Joint axes

Ok, that should work, thank you for the support
Birdlegs
Scratcher
1000+ posts

Joint axes

blender67 wrote:

Ok, that should work, thank you for the support
No problem ;D

Get a sweet lick of my new game right here! It's a tasty one!
-Scratcher-
Scratcher
100+ posts

Joint axes

Or trigonometrical
Attach Sprite2 to Sprite1:
when green flag clicked
set [distance v] to [50] //distance from Sprite1's midpoint
set [angle v] to [0] //shifted angle from Sprite1
forever
set x to (([x position v] of [Sprite1 v]) + ((distance) * ([sin v] of (([direction v] of [Sprite1 v]) + (angle)))))
set y to (([y position v] of [Sprite1 v]) + ((distance) * ([cos v] of (([direction v] of [Sprite1 v]) + (angle)))))
end

Last edited by -Scratcher- (May 28, 2015 11:47:39)

blender67
Scratcher
10 posts

Joint axes

-Scratcher- wrote:

Or trigonometrical
Attach Sprite2 to Sprite1:
when green flag clicked
set [distance v] to [50] //distance from Sprite1's midpoint
set [angle v] to [0] //shifted angle from Sprite1
forever
set x to (([x position v] of [Sprite1 v]) + ((distance) * ([sin v] of (([direction v] of [Sprite1 v]) + (angle)))))
set y to (([y position v] of [Sprite1 v]) + ((distance) * ([cos v] of (([direction v] of [Sprite1 v]) + (angle)))))
end


Thanks
blender67
Scratcher
10 posts

Joint axes

And how would the right leg vary?
-Scratcher-
Scratcher
100+ posts

Joint axes

blender67 wrote:

And how would the right leg vary?
You just have to set the midpoint for each body part, which is usually the joint with the “parented” body part. The easiest and safest way is to use the triginomical scripts, you just have to play around a bit with the values.
If you need help, I once made a project about this, just click see inside to see how I did it https://scratch.mit.edu/projects/1138616/
blender67
Scratcher
10 posts

Joint axes

-Scratcher- wrote:

blender67 wrote:

And how would the right leg vary?
You just have to set the midpoint for each body part, which is usually the joint with the “parented” body part. The easiest and safest way is to use the triginomical scripts, you just have to play around a bit with the values.
If you need help, I once made a project about this, just click see inside to see how I did it https://scratch.mit.edu/projects/1138616/
That doesn't help very much though.
What values can I change specifically?
-Scratcher-
Scratcher
100+ posts

Joint axes

blender67 wrote:

-Scratcher- wrote:

blender67 wrote:

And how would the right leg vary?
You just have to set the midpoint for each body part, which is usually the joint with the “parented” body part. The easiest and safest way is to use the triginomical scripts, you just have to play around a bit with the values.
If you need help, I once made a project about this, just click see inside to see how I did it https://scratch.mit.edu/projects/1138616/
That doesn't help very much though.
What values can I change specifically?
Just use the script I postet above ↑. You can change the values of the variables “distance” and “angle” before starting the project, they stay constant while the project is running though.

Just follow these instructions:
- Add two new Sprites: Sprite1, Sprite2.
- For each Sprite1 and Sprite2, draw a long, narrow rectangle as a costume and center them in the middle of the shortest edge.
- For Sprite2, add the exact script I postet already. Before, you have to create these two variables. When you're done with it, make them show on the screen by clicking the checkbox of each variable under the data tab.
- Move the variables on the screen, double click until they change to the slider and set the slider min and max (right-click) for each: For the distance variable from 0 to 200; for the angle variable from 0 to 360.
- Now click the green flag and change these values while rotating Sprite1, you will see what these two values are going to do and then you will understand for your project

Last edited by -Scratcher- (May 30, 2015 22:22:50)

blender67
Scratcher
10 posts

Joint axes

Thank you so much!
-Scratcher-
Scratcher
100+ posts

Joint axes

blender67 wrote:

Thank you so much!
You're welcome! If you have more questions or there is something going wrong, just let me know.
WizardQuest
Scratcher
16 posts

Joint axes

im curious what do u mean by save its direction as a variable?
deck26
Scratcher
1000+ posts

Joint axes

WizardQuest wrote:

im curious what do u mean by save its direction as a variable?
Create a variable, save the direction in that variable.
WizardQuest
Scratcher
16 posts

Joint axes

Can you tell me how to do that? I'm kind of a newbie at this. I've been on scratch offline for about a year.
Birdlegs
Scratcher
1000+ posts

Joint axes

Just create a new variable and have the sprite set the variable to its direction, like this:

set [variable v] to (direction)

Get a sweet lick of my new game right here! It's a tasty one!
himahnamesbob
Scratcher
1 post

Joint axes

i still dont get it :C
robnet
Scratcher
6 posts

Joint axes

Any solutions with scratch 3.0?
daniscratch2234
Scratcher
6 posts

Joint axes

help me
abcde1234qwe
Scratcher
500+ posts

Joint axes

daniscratch2234 wrote:

help me
Please don't necropost. (Necroposting means you post on an old topic).
If you would want help, please create a new topic and explain what you need help with,

View my new project please.
–> Learn About Scratch Blocks! <–

500+ posts let's go.
Helper in the Help with Scripts topic.

Powered by DjangoBB