Discuss Scratch

WizardQuest
Scratcher
16 posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Is there a way to make two sprites stay together at a point that isn't their sprite center? This is of course during the event that the first sprite be moving, I just want to make the second sprite go to the same location relative to the first sprite, even if the first sprite points in a different direction. An example would be kind of like a one sprite arm, and let's say the center is at the shoulder. The arm rotates around the shoulder. At the end of the arm there is a hand, but the hand is a separate sprite, how would I make the hand stay with the arm while at the same time having them both different sprites?
gor-dee
Scratcher
1000+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

gotoarmpointindirectiondirectionofarm movelengthofarmsteps

in a without refresh block?

Last edited by gor-dee (May 24, 2016 20:47:32)

footsocktoe
Scratcher
1000+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

WizardQuest wrote:

Is there a way to make two sprites stay together at a point that isn't their sprite center? This is of course during the event that the first sprite be moving, I just want to make the second sprite go to the same location relative to the first sprite, even if the first sprite points in a different direction. An example would be kind of like a one sprite arm, and let's say the center is at the shoulder. The arm rotates around the shoulder. At the end of the arm there is a hand, but the hand is a separate sprite, how would I make the hand stay with the arm while at the same time having them both different sprites?

The sprite is defined by it's costume center and bounding box, so when you use commands like telling one sprite to GoTo another sprite, the sprites' two costume centers approach each other. “Touching” takes place when their bounding boxes collide.

Does that help you see what happens?

And you also have to take the sprite's “direction” orientation into consideration.

Experiment with it.

Last edited by footsocktoe (May 24, 2016 19:29:19)

WizardQuest
Scratcher
16 posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Could you further explain what a bounding box is please? I've been on long enough to become a scratcher but I'm still pretty new and I feel like I am really just “Scratching” the surface of what I can do here.

Last edited by WizardQuest (May 24, 2016 14:15:55)

WizardQuest
Scratcher
16 posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Also, what is the red block that gor-dee has on his example program, I'm curious.
footsocktoe
Scratcher
1000+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

WizardQuest wrote:

Could you further explain what a bounding box is please? I've been on long enough to become a scratcher but I'm still pretty new and I feel like I am really just “Scratching” the surface of what I can do here.

Nothing mysterious about the bounding box. It's the smallest box that will still contain all of the sprite. For example, a character sprite with his arms by his side would have a tall narrow bounding box, but if he stretched his arms out, the bounding box would increase in width. It changes how close he would get to another sprite before they “touch”.
footsocktoe
Scratcher
1000+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

WizardQuest wrote:

Also, what is the red block that gor-dee has on his example program, I'm curious.

He put a “v” after his sensor block and Scratch didn't recognize that construction and so colored it red.

Last edited by footsocktoe (May 24, 2016 19:30:52)

WizardQuest
Scratcher
16 posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Thank you.
Brontosplachna
Scratcher
100+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Here is a simple version of rotating limbs. The arms and legs follow the body pretty much as @gor-dee said above.

I would guess that adding hands would not be too difficult. The arm sprite has its “costume center” at its shoulder. The arm sprite happens to be pointed in the direction of its hand. So, put the costume center of the new hand sprite at its wrist. Make sure the hand is pointing in the same direction the arm is in the costume editor. Then, after running the code to move and rotate the arm, the hand can be positioned with
goto armpointindirectiondirectionofarm movelengthofarmsteps

At that point the hand can be rotated around the wrist while remaining connected to the arm.

There is probably a timing issue in moving the body, then moving the arm, then moving the hand, so that the hand doesn't lag behind.





asivi
Scratcher
1000+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Brontosplachna wrote:

Here is a simple version of rotating limbs.
Great!
Here https://scratch.mit.edu/projects/111167320/ a remix.
unipiggy123
Scratcher
1 post

I need help to make a sprite stay at a relative distance to another moving sprite.

gor-dee wrote:

gotoarmpointindirectiondirectionofarm movelengthofarmsteps

in a without refresh block?
deck26
Scratcher
1000+ posts

I need help to make a sprite stay at a relative distance to another moving sprite.

unipiggy123 wrote:

gor-dee wrote:

gotoarmpointindirectiondirectionofarm movelengthofarmsteps

in a without refresh block?
Probably too late to post a question here - the topic is old. Better to try it and create a new topic if you need help, sharing what you have.
rebzelgamer
Scratcher
8 posts

I need help to make a sprite stay at a relative distance to another moving sprite.

Last edited by rebzelgamer (Sept. 11, 2021 16:56:06)

Powered by DjangoBB