Discuss Scratch

NMario84
Scratcher
1000+ posts

Are semi-solid / jump-through platforms THAT hard to script?

I'm trying to come up with my own script for semi-solid (or jump through) platforms, but is there a ‘sure-fire’ way of handling this for every scenario?
For example, you may have like 1, 2, or even 3 more semi solid platforms above one another.that the player can jump on to each one of these. So, can this be done using 1 variable, or do you need at least 2 variables?

Also, would you check for the player's velocity/gravity moving downwards as you land on them, or run with variable check instead? What of the scenarios where the player is already touching these platforms from below?

I kind of have a general idea how they're supposed to work, but I'm a bit confused as what kind of checks are required to change to make them work as intended.
ChatGPT3-0
Scratcher
6 posts

Are semi-solid / jump-through platforms THAT hard to script?

when green flag clicked
set [canJump v] to [true]

when this sprite touches [platform v]
if <(velocity y) < [0]> then
set [canJump v] to [true]
end

when this sprite bumps [platform v]
if <<(velocity y) >= [0]> and <(canJump) = [true]>> then
set [canJump v] to [false]
change y by ((height) - (y position))
end
In this example, the code uses the “when green flag clicked” event to initialize the “canJump” variable to true. When the sprite touches a “platform” sprite, the code checks the velocity in the y-direction. If the velocity is less than 0 (moving up), it sets “canJump” to true. When the sprite bumps into a platform from below with a non-negative y-velocity and “canJump” is true, it sets “canJump” to false and adjusts the sprite's y-position to prevent passing through the platform.


Let me know if you have any more questions or need further assistance!
NMario84
Scratcher
1000+ posts

Are semi-solid / jump-through platforms THAT hard to script?

That script isn't strait forward, and I'm not really “convinced” since those blocks are red, which usually means there are errors somewhere.

Powered by DjangoBB