Discuss Scratch

No-Sider
Scratcher
100+ posts

Need help translating code into scratch blocks

Hello, Im wondering if anyone can help me translate this code

Into Scratch Blocks

In particular vel & wishdir being vectors and getting the dot product is what is giving me the most trouble
DavideProgrammer
Scratcher
54 posts

Need help translating code into scratch blocks

set [RUN_SPEED] to [320]
set [MAX_ACCEL] to [320]

set [currentspeed] to (dot)
set [addspeed] to ((RUN_SPEED) - (currentspeed))
set [addspeed] to ((RUN_SPEED) + ((currentspeed) * (frametime)))
set [return vel] to ((vel) + ((wishdir) * (addspeed)))

If you have found this helpful, please consider following me
No-Sider
Scratcher
100+ posts

Need help translating code into scratch blocks

DavideProgrammer wrote:

*snip*

If you have found this helpful, please consider following me

But how would I find the dot product for current speed?
PhiPhenomenon
Scratcher
500+ posts

Need help translating code into scratch blocks

Didn't see your post above, sorry.

DavideProgrammer wrote:

set [RUN_SPEED] to [320]
set [MAX_ACCEL] to [320]

set [currentspeed] to (dot)
set [addspeed] to ((RUN_SPEED) - (currentspeed))
set [addspeed] to ((RUN_SPEED) + ((currentspeed) * (frametime)))
set [return vel] to ((vel) + ((wishdir) * (addspeed)))
The currentspeed variable is a dot product (aka how closely two vectors align), not defined as a variable named dot. I believe this project can help to find a dot product between two vectors.

Last edited by PhiPhenomenon (April 14, 2023 15:23:49)

Powered by DjangoBB