This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-06-15 00:49:01

croatoan
Scratcher
Registered: 2008-01-25
Posts: 12

I need help with something! PLZ! :)

So i have a character, and i want him to pick up an item and drop it. I want him to pick it up with the space button and make it perminately follow him until i press the space button again. I've been trying many ways of achieving this but nothing seems to work. Can anyone help me? Help is appreciated and i promise to check out your projects if you help me.

Offline

 

#2 2010-06-15 02:15:00

mooseofawesomeness
Scratcher
Registered: 2010-06-09
Posts: 500+

Re: I need help with something! PLZ! :)

This goes in all about scratch, I think.
On topic, you would have when flag clicked forever if key space pressed and object following=0 wait 0.1 sec set object following to 1
if key space pressed and object following=1 wait 0.1 sec set object following to 0
Them just have the script for the following object run if object following = 1.
Hope I helped!


I am urhungry's alternate account with a cooler username. Your argument is invalid.

Offline

 

#3 2010-06-15 11:41:22

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: I need help with something! PLZ! :)

a complete tutorial (not criticizing moose though  smile  ):

make a variable called 'following?'
in the stage, add this script: [blocks]
<when[ space ]key pressed>
<if><( <{ follow? }> <=> true )>
<set{ follow? }to( false
<else>
<set{ follow? }to( true
<end>
[/blocks]
in the object that is to be picked up, add this script:
[blocks]
<when green flag clicked>
<forever if> <( <{ follow? }> <=> true )>
<go to x sad  xPosition of player )y sad  (( yPos of player <-> 10 ))
<end>
[/blocks]
that should work. you can adjust the yPosition to match the size of the sprite.

sorry it's a bit messy  hmm

Last edited by LS97 (2010-06-15 11:42:09)

Offline

 

#4 2010-06-15 11:45:08

Wolfie1996
Retired Community Moderator
Registered: 2009-07-08
Posts: 1000+

Re: I need help with something! PLZ! :)

Looks like this should be in All About Scratch... No problem - I'll move it over there for you  smile


"...Jargon - the practice of never calling a spade a spade, when you might instead call it a manual earth-restructing implement..." - Bill Bryson, Mother Tongue

Offline

 

#5 2010-06-15 11:47:59

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: I need help with something! PLZ! :)

@wolfie1996:
thanks! btw, great job as a mod here...

Offline

 

#6 2010-06-15 16:58:06

croatoan
Scratcher
Registered: 2008-01-25
Posts: 12

Re: I need help with something! PLZ! :)

Thanks for moving the post for me!   smile   i figured it out, it works best like this:
<when green flag clicked>
<set{ FOLLOW }to( -1 )
<forever>
<if><< <touching[ Character 1 ] <and> <key[ Space ]pressed?> >>
<set{ FOLLOW }to( (( FOLLOW <*> -1 ))
<end>
<if><( FOLLOW <=> 1 )>
<go to[ Character 1 ]
<end>
<end>

Offline

 

Board footer