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

#1 2012-09-09 11:08:56

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Getting a Sprite to Stop Bouncing

I'm trying to make a movement engine, and I want the player to stop bouncing. How should I do it? It doesn't scroll, and it uses velocities.

Offline

 

#2 2012-09-09 11:13:25

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Getting a Sprite to Stop Bouncing

set [Yvelocity] to (0)
Or whatever you've called the velocity variable.


http://i48.tinypic.com/5a25g5.png

Offline

 

#3 2012-09-09 11:14:05

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

Where do I put it?

Offline

 

#4 2012-09-09 13:11:38

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

Bump

Offline

 

#5 2012-09-09 15:26:43

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Getting a Sprite to Stop Bouncing

Tatl wrote:

Where do I put it?

In your velocity script. Use something like this:

when gf clicked
forever
 if <touching [ground v]?>
  set [Yvelocity v] to [0]
 else
  set [Yvelocity v] to ((Yvelocity) * (0.89))
 end
end


http://i50.tinypic.com/312u714.jpg

Offline

 

#6 2012-09-09 16:39:12

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

That doesn't provide gravity though.

I'm new, so please be more specific. Right now my script looks like this:

when gf clicked
forever
if <touching [ground v]>
set [yvelocity v] to 0 
if <key [up arrow v] pressed?>
set [y velocity v]
end
else
set [yvelocity v] to ((yvelocity) * (89))
end
end
What am I doing wrong? That doesn't provide any gravity at all.

Offline

 

#7 2012-09-09 17:09:26

northmeister
Scratcher
Registered: 2011-07-12
Posts: 1000+

Re: Getting a Sprite to Stop Bouncing

Are you setting the y position to the y velocity?


http://i48.tinypic.com/5a25g5.png

Offline

 

#8 2012-09-09 17:47:48

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

Yes, but I forgot to put that in the script.

Everything else is just like it is above. Without the mistakes I made typing.

It jumps when I press up, and then it just slows to a halt, and doesn't come down. I think it's because of the [set [yvelocity v] to ((yvelocity) * (89))] block, but I'm not sure.

Offline

 

#9 2012-09-09 18:10:46

powerpoint56_test
New Scratcher
Registered: 2012-07-24
Posts: 2

Re: Getting a Sprite to Stop Bouncing

I think the issue is that the 89 in the "((y-vel) * (89)) should be a 0.89, unless that was just a typing mistake you made.

Offline

 

#10 2012-09-09 18:12:00

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: Getting a Sprite to Stop Bouncing

powerpoint56_test wrote:

I think the issue is that the 89 in the "((y-vel) * (89)) should be a 0.89, unless that was just a typing mistake you made.

lol

I never use that account on the forums... oops...  big_smile


http://i48.tinypic.com/2072ctw.gif

Offline

 

#11 2012-09-09 20:06:24

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

*Facepalm* Silly me.  tongue

I accidentally type 89 instead of 0.89, which is what I meant.

Offline

 

#12 2012-09-09 20:10:51

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Getting a Sprite to Stop Bouncing

Tatl wrote:

That doesn't provide gravity though.

I'm new, so please be more specific. Right now my script looks like this:

when gf clicked
forever
 if <touching [ground v]?>
  set [yvelocity v] to (0)
 end
 if <<key [up arrow v] pressed?> and <touching [ground v]?>>
  set [yvelocity v] to (5)//Or whatever you have.
 else
  change [yvelocity v] by (-1)//Change this to change gravity's strength.
 end
end
What am I doing wrong? That doesn't provide any gravity at all.

Edited and fixed.

Anyway, the reason why your character never fell to the ground was because it would eventually set yvelocity to 0 and yvelocity wouldn't go negative, therefore causing the floating effect. You have to have
[change [yvelocity v] by (some negative number)] or else you will always get a floating effect.

Last edited by ErnieParke (2012-09-09 20:23:51)


http://i46.tinypic.com/35ismmc.png

Offline

 

#13 2012-09-09 23:43:31

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

ErnieParke wrote:

Tatl wrote:

That doesn't provide gravity though.

I'm new, so please be more specific. Right now my script looks like this:

when gf clicked
forever
 if <touching [ground v]?>
  set [yvelocity v] to (0)
 end
 if <<key [up arrow v] pressed?> and <touching [ground v]?>>
  set [yvelocity v] to (5)//Or whatever you have.
 else
  change [yvelocity v] by (-1)//Change this to change gravity's strength.
 end
end
What am I doing wrong? That doesn't provide any gravity at all.

Edited and fixed.

Anyway, the reason why your character never fell to the ground was because it would eventually set yvelocity to 0 and yvelocity wouldn't go negative, therefore causing the floating effect. You have to have
[change [yvelocity v] by (some negative number)] or else you will always get a floating effect.

That works pretty well and all, but the player's legs keep getting stuck in the ground and he won't go up.

Is there a way to make the player go up when under ground, but not bounce?

Offline

 

#14 2012-09-10 00:03:22

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

Hey guys! Just wanted to let you know, I fixed it all up using this script:

http://i47.tinypic.com/35a95xs.gif

Thanks for all your help, though.  smile

Offline

 

#15 2012-09-10 20:30:43

Tatl
Scratcher
Registered: 2012-09-09
Posts: 37

Re: Getting a Sprite to Stop Bouncing

Oops, I forgot to report the topic.

Offline

 

#16 2012-09-10 20:33:32

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: Getting a Sprite to Stop Bouncing

Closed by request.


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

Board footer