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

#1 2012-08-14 12:07:55

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Non-bouncing ground detection

I'm working on a velocities project, but I want to know how to have a ground detection that doesn't bounce.  Any help?


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#2 2012-08-14 12:21:33

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Non-bouncing ground detection

Why is nobody helping me?   sad


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#3 2012-08-14 12:23:41

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

Re: Non-bouncing ground detection

Do you have a separate sensor sprite?


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

Offline

 

#4 2012-08-14 12:24:18

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Non-bouncing ground detection

No.  I know it can be done without one.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#5 2012-08-14 12:28:13

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Non-bouncing ground detection

have it so that when you're touching the ground, yvel is set to


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#6 2012-08-14 12:31:03

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Non-bouncing ground detection

Set to what?  My y vel is set to 1 if up key pressed or else -1 if down, and set yv to yv*.9


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#7 2012-08-14 12:36:41

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

Re: Non-bouncing ground detection

Firedrake969 wrote:

No.  I know it can be done without one.

Okay.
*optimizes script*
You'll need sensing costumes, then.
Copy the character sprite. Make a red line under the sprite about half the width of the sprite. Erase the character. OK. Do this for each side.

Now, add this script at the beginning of your loop:

switch to costume [sensor_top v]
if <touching [ground v]?>
 set [topsense v] to [1]
else
 set [topsense v] to [0]
end
switch to costume [sensor_right v]
if <touching [ground v]?>
 set [rightsense v] to [1]
else
 set [rightsense v] to [0]
end
switch to costume [sensor_bottom v]
if <touching [ground v]?>
 set [bottomsense v] to [1]
else
 set [bottomsense v] to [0]
end
switch to costume [sensor_left v]
if <touching [ground v]?>
 set [leftsense v] to [1]
else
 set [leftsense v] to [0]
end
You gravity will be something like this:
if <(bottomsense) = [0]>
 change [vel v] by (-0.1)
 change y by (vel)
else
 set [vel v] to [0]
end
Don't forget to add
<<> and <(leftsense) = [0]>>
etc. to your movement and
if <<(topsense) = [1]> and <(vel) > [0]>>
 set [vel v] to ((vel) * (-0.8))
end
before your gravity script.  smile


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

Offline

 

#8 2012-08-14 12:40:41

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Non-bouncing ground detection

Maybe I should upload it to show you.... this.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#9 2012-08-14 12:52:32

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

Re: Non-bouncing ground detection

My script should work with the color sensor block...


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

Offline

 

#10 2012-08-14 12:53:58

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

Re: Non-bouncing ground detection

Here's the issue. On the

if <key [up-arrow v] pressed?>
change [yv v] by (1)
else
change [yv v] by (-1)
end
The issue is, when you aren't jumping, you'll always be sinking, so even if you're touching the ground and the yvelocity is 0, it will immediately be set to -1 unless you're jumping again. So, replace that part of the script with this:

if <key [up-arrow v] pressed?>
change [yv v] by (1)
end
if <not<touching color [#000000]?>>
change [yv v] by (-1)
end
Hope this helps!

Last edited by powerpoint56 (2012-08-14 15:20:15)


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

Offline

 

#11 2012-08-14 15:03:10

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Non-bouncing ground detection

powerpoint56 wrote:

Here's the issue. On the

if <key [up-arrow v] pressed?>
change [yv v] by (1)
else
change [yv v] by (-1)
end
The issue is, when you aren't jumping, you'll always be sinking, so even if you're touching the ground and the yvelocity is 0, it will immediately be set to -1 unless you're jumping again. So, replace that part of the script with this:

if <key [up-arrow v] pressed?>
change [yv v] by (1)
if <not<touching color [#000000]?>>
change [yv v] by (-1)
end
Hope this helps!

The problem with that is I need the guy to fly. Darn this new scratcher status.


Alt of Firedrake969.

Offline

 

#12 2012-08-14 15:20:42

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

Re: Non-bouncing ground detection

firedrake969_test wrote:

powerpoint56 wrote:

Here's the issue. On the

if <key [up-arrow v] pressed?>
change [yv v] by (1)
else
change [yv v] by (-1)
end
The issue is, when you aren't jumping, you'll always be sinking, so even if you're touching the ground and the yvelocity is 0, it will immediately be set to -1 unless you're jumping again. So, replace that part of the script with this:

if <key [up-arrow v] pressed?>
change [yv v] by (1)
end
if <not<touching color [#000000]?>>
change [yv v] by (-1)
end
Hope this helps!

The problem with that is I need the guy to fly. Darn this new scratcher status.

Hmm... Wait, he can! Try it...

Last edited by powerpoint56 (2012-08-14 15:21:13)


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

Offline

 

#13 2012-08-14 22:21:09

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Non-bouncing ground detection

powerpoint56 wrote:

firedrake969_test wrote:

powerpoint56 wrote:

Here's the issue. On the

if <key [up-arrow v] pressed?>
change [yv v] by (1)
else
change [yv v] by (-1)
end
The issue is, when you aren't jumping, you'll always be sinking, so even if you're touching the ground and the yvelocity is 0, it will immediately be set to -1 unless you're jumping again. So, replace that part of the script with this:

if <key [up-arrow v] pressed?>
change [yv v] by (1)
end
if <not<touching color [#000000]?>>
change [yv v] by (-1)
end
Hope this helps!

The problem with that is I need the guy to fly. Darn this new scratcher status.

Hmm... Wait, he can! Try it...

Something still isn't working....


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#14 2012-08-15 09:40:11

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Non-bouncing ground detection

Is this a "build your own terrain" type game or is the stamping sprite only for testing?  In essence, is your sprite going to have to be able to detect slopes?


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#15 2012-08-15 12:09:46

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Non-bouncing ground detection

MoreGamesNow wrote:

Is this a "build your own terrain" type game or is the stamping sprite only for testing?  In essence, is your sprite going to have to be able to detect slopes?

Yes, slope detection.  And it's not Build your own terrain, it's just for something like Worm Bridges.  But better.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#16 2012-08-15 14:55:19

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: Non-bouncing ground detection

If you don't want a sensor sprite, you could try playing around with this. It's a bit hard to use, and there's no swimming, but it's definitely a good base.


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#17 2012-08-15 21:17:41

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Non-bouncing ground detection

henley wrote:

If you don't want a sensor sprite, you could try playing around with this. It's a bit hard to use, and there's no swimming, but it's definitely a good base.

For the swimming it's just if touching blue change y by 1


Alt of Firedrake969.

Offline

 

#18 2012-08-15 21:22:35

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: Non-bouncing ground detection

firedrake969_test wrote:

henley wrote:

If you don't want a sensor sprite, you could try playing around with this. It's a bit hard to use, and there's no swimming, but it's definitely a good base.

For the swimming it's just if touching blue change y by 1

You'd have to do a lot more changes than that to make swimming more realistic, and not just floaty running.


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#19 2012-08-15 21:26:49

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Non-bouncing ground detection

henley wrote:

firedrake969_test wrote:

henley wrote:

If you don't want a sensor sprite, you could try playing around with this. It's a bit hard to use, and there's no swimming, but it's definitely a good base.

For the swimming it's just if touching blue change y by 1

You'd have to do a lot more changes than that to make swimming more realistic, and not just floaty running.

Could you help me then?


Alt of Firedrake969.

Offline

 

#20 2012-08-15 22:52:21

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: Non-bouncing ground detection

firedrake969_test wrote:

henley wrote:

firedrake969_test wrote:


For the swimming it's just if touching blue change y by 1

You'd have to do a lot more changes than that to make swimming more realistic, and not just floaty running.

Could you help me then?

What do you want? I might help.


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

Board footer