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
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!
Offline
a complete tutorial (not criticizing moose though ):
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 xPosition of player )y (( 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
Last edited by LS97 (2010-06-15 11:42:09)
Offline
Looks like this should be in All About Scratch... No problem - I'll move it over there for you
Offline
@wolfie1996:
thanks! btw, great job as a mod here...
Offline
Thanks for moving the post for me! 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