Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » My running script isnt working
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
first person to get it gets a love on their featured project so click here
- deck26
-
Scratcher
1000+ posts
My running script isnt working
If you're not touching the platform you change y until you are. But when you are touching the platform x is set to 0 each time in the forever loop.
- deck26
-
Scratcher
1000+ posts
My running script isnt working
I'd also change the costume changing script to do next costume whenever x is non-zero if you want movement to slow gradually when the key is released.
Edit - actually make that something like this
Edit - actually make that something like this
if <([abs v] of (x)) > [0.2 ]> then
next costume
else
set (x) to [0]
end
Last edited by deck26 (May 16, 2015 14:19:36)
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
If you're not touching the platform you change y until you are. But when you are touching the platform x is set to 0 each time in the forever loop.So what do you recommend I do?
- deck26
-
Scratcher
1000+ posts
My running script isnt working
You're presumably trying to get it to stop when it touches the vertical face of the block so you need to treat that separately from the ground. But if you're on top of the block you still want to be able to move so you need to treat the horizontal top differently from the vertical faces. One option is to use ‘if touching color’ for that and have a different colour for the vertical faces.If you're not touching the platform you change y until you are. But when you are touching the platform x is set to 0 each time in the forever loop.So what do you recommend I do?
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
k ill try that thxYou're presumably trying to get it to stop when it touches the vertical face of the block so you need to treat that separately from the ground. But if you're on top of the block you still want to be able to move so you need to treat the horizontal top differently from the vertical faces. One option is to use ‘if touching color’ for that and have a different colour for the vertical faces.If you're not touching the platform you change y until you are. But when you are touching the platform x is set to 0 each time in the forever loop.So what do you recommend I do?
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
yay it workedk ill try that thxYou're presumably trying to get it to stop when it touches the vertical face of the block so you need to treat that separately from the ground. But if you're on top of the block you still want to be able to move so you need to treat the horizontal top differently from the vertical faces. One option is to use ‘if touching color’ for that and have a different colour for the vertical faces.If you're not touching the platform you change y until you are. But when you are touching the platform x is set to 0 each time in the forever loop.So what do you recommend I do?
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
I'd also change the costume changing script to do next costume whenever x is non-zero if you want movement to slow gradually when the key is released.what do u mean by “abs”
Edit - actually make that something like thisif <([abs v] of (x)) > [0.2 ]> then
next costume
else
set (x) to [0]
end
- deck26
-
Scratcher
1000+ posts
My running script isnt working
You're getting into the territory that most platform games hit in terms of detecting the ground and obstacles and handling x and y velocities correctly without sinking into the ground etc. I can usually work round the problems but there are lots of people who are more experienced in that area than I am so if you have further problems it might be worth opening a new topic.
By the way, I don't help to get loves or favs so it is entirely up to you whether you look at any of my projects and do anything like that. I'd much rather such tributes were deserved by the project than just somehow earned by other means.
By the way, I don't help to get loves or favs so it is entirely up to you whether you look at any of my projects and do anything like that. I'd much rather such tributes were deserved by the project than just somehow earned by other means.
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
You're getting into the territory that most platform games hit in terms of detecting the ground and obstacles and handling x and y velocities correctly without sinking into the ground etc. I can usually work round the problems but there are lots of people who are more experienced in that area than I am so if you have further problems it might be worth opening a new topic.im definitely going to do it since u helped me so much
By the way, I don't help to get loves or favs so it is entirely up to you whether you look at any of my projects and do anything like that. I'd much rather such tributes were deserved by the project than just somehow earned by other means.
- deck26
-
Scratcher
1000+ posts
My running script isnt working
abs = absolute. It gives the ‘size’ of a number regardless of sign so abs of minus 9 is the same as abs(9) = 9. Since x will be negative if moving left it saves us dealing with that separately. What the block is saying is only do the next costume if x isn't within 0.2 of 0.I'd also change the costume changing script to do next costume whenever x is non-zero if you want movement to slow gradually when the key is released.what do u mean by “abs”
Edit - actually make that something like thisif <([abs v] of (x)) > [0.2 ]> then
next costume
else
set (x) to [0]
end
On the subject of moving left - you should set the sprite to only rotate left-right and then point it in direction -90 for left and 90 for right.
Last edited by deck26 (May 16, 2015 14:44:41)
- Billy_Bob_Joe_Fred
-
Scratcher
49 posts
My running script isnt working
okabs = absolute. It gives the ‘size’ of a number regardless of sign so abs of minus 9 is the same as abs(9) = 9. Since x will be negative if moving left it saves us dealing with that separately. What the block is saying is only do the next costume if x isn't within 0.2 of 0.I'd also change the costume changing script to do next costume whenever x is non-zero if you want movement to slow gradually when the key is released.what do u mean by “abs”
Edit - actually make that something like thisif <([abs v] of (x)) > [0.2 ]> then
next costume
else
set (x) to [0]
end
On the subject of moving left - you should set the sprite to only rotate left-right and then point it in direction -90 for left and 90 for right.
- Discussion Forums
- » Help with Scripts
-
» My running script isnt working